Skip to content

Instantly share code, notes, and snippets.

View sempr's full-sized avatar

Sempr sempr

  • Company-Not-Be-Named
  • Hangzhou
  • 04:24 (UTC +08:00)
View GitHub Profile
@sempr
sempr / codeforces-sample-download.user.js
Created May 14, 2024 05:56
Codeforces Data Donwloader
// ==UserScript==
// @name Codeforces Data Donwloader
// @namespace http://tampermonkey.net/
// @version 2024-05-14
// @description Download Script For Codeforces
// @author Sempr
// @match https://codeforces.com/contest/*/problems
// @icon https://aowuucdn.oss-accelerate.aliyuncs.com/codeforces.png
// @grant GM_addStyle
// @require https://cdnjs.cloudflare.com/ajax/libs/jszip/3.7.1/jszip.min.js
@sempr
sempr / default.conf
Last active January 11, 2024 06:48
nginx rate limit config sample
# https://zhaox.github.io/nginx/2019/09/05/explain-nginx-rate-limit
# 20 per second, 50ms each
limit_req_zone $remote_user zone=user_limit:10m rate=10r/s;
limit_req_zone $my_id zone=one:10m rate=20r/m;
server {
listen 80;
listen [::]:80;
server_name localhost;
@sempr
sempr / go.mod
Created August 9, 2022 07:28
Gin with httputil.ReverseProxy
module github.com/sempr/gin-reverse-proxy
go 1.18
require github.com/gin-gonic/gin v1.8.1
require (
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
@sempr
sempr / ding_send.sh
Created August 27, 2021 03:19
Send DingTalk with shell and sign
#!/bin/bash
DING_SEC="<Your SEC Here>"
DING_URL="<Your Webhook Here>"
function hash_hmac {
# hash_hmac sha256 data sec -binary
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
digest="$1"
@sempr
sempr / relations.go
Created January 18, 2021 23:40
Relations Demo
package main
import (
"fmt"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"gorm.io/gorm/logger"
)
@sempr
sempr / docker-compose.yml
Created October 14, 2020 09:48
docker-compose, extend
version: "3.8"
x-superenv:
&default-superenv
environment:
XX: 135
FOO: superenv-foo
command: echo $${XX} $${FOO}
services:
@sempr
sempr / install_docker.sh
Created July 20, 2020 02:49
centos8 docker install
dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
dnf install -y https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.13-3.2.el7.x86_64.rpm
dnf install -y docker-ce
curl -o /usr/local/bin/docker-compose -L https://github.com/docker/compose/releases/download/1.26.2/docker-compose-Linux-x86_64
chmod +x /usr/local/bin/docker-compose
systemctl enable --now docker
#dnf install -y git
@sempr
sempr / Dockerfile
Created February 12, 2020 05:39
Flask&Pillow&Docker
FROM python:3.8.1-slim
ADD ./requirements.txt /tmp/requirements.txt
RUN set -xe \
&& pip install -i https://mirrors.aliyun.com/pypi/simple --no-cache -r /tmp/requirements.txt
ADD app.py /code/app.py
WORKDIR /code
CMD ["gunicorn", "-w4", "-b0.0.0.0:8000", "app:app"]
@sempr
sempr / main.go
Created February 3, 2020 13:47
Composition Instead of Inheritance, golang
package main
import (
"path"
"github.com/gin-gonic/gin"
)
type oauthApp struct {
Prefix string
@sempr
sempr / replace-new-kernel.sh
Last active February 3, 2021 09:52
使用kexec来替换新内核
latestkernel=`ls -t /boot/vmlinuz-* | sed "s/\/boot\/vmlinuz-//g" | head -n1`
echo $latestkernel
kexec -l /boot/vmlinuz-${latestkernel} --initrd=/boot/initramfs-${latestkernel}.img --append="`cat /proc/cmdline`"
kexec -e
# 备注,其实和重启没啥两样, uptime也会清零重算,唯一的好处就是比重启要快一点点
# remove old kernels on centos 8
dnf remove --oldinstallonly --setopt installonly_limit=1 kernel