Skip to content

Instantly share code, notes, and snippets.

View sempr's full-sized avatar

Sempr sempr

  • Company-Not-Be-Named
  • Hangzhou
  • 15:00 (UTC +08:00)
View GitHub Profile
@sempr
sempr / ip.txt
Last active February 2, 2023 11:50
proxy check by golang
129.24.51.99 21320
24.158.231.6 80
54.161.139.184 5555
46.38.166.124 80
192.121.107.107 80
177.91.192.116 8080
1.0.138.14 8080
107.150.29.157 3128
98.145.71.245 21320
68.195.17.204 21320
@sempr
sempr / coupon.user.js
Last active May 9, 2018 10:17
Coupons
// ==UserScript==
// @name 找券
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http*://item.taobao.com/item.htm*
// @match http*://detail.tmall.com/item.htm*
// @require https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js
// @grant GM_xmlhttpRequest
@sempr
sempr / run_leap_year.py
Created July 4, 2018 05:06
RunLeapYear Speed Test
def is_leap_year1(y):
return (y % 4 == 0 and y % 100 != 0) or (y % 400 == 0)
def is_leap_year2(y):
return (y % 400 == 0) or (y % 4 == 0 and y % 100 != 0)
def is_leap_year3(y):
return (y % 4 == 0) and (y % 400 == 0 or y % 100 != 0)
@sempr
sempr / new.py
Created July 4, 2018 08:38
new.py
#coding:utf8
def is_leap_year(y):
"""闰年判断 这样最快"""
return (y % 4 == 0) and (y % 100 != 0 or y % 400 == 0)
def leap_count(year):
"""从0年开始的闰年数量(不包含0年)"""
return year // 4 - year // 100 + year // 400
@sempr
sempr / new0705.py
Last active July 5, 2018 03:19
0705.py
#coding:utf8
import sys
## prepare
d_arr = (
(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31),
(0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
)
ds_arr = (
(None, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365),
@sempr
sempr / Dockerfile
Last active August 16, 2018 03:39
pycryptodome/eventlet not work at the same time
FROM python:2-alpine
RUN sed -i "s|dl-cdn.alpinelinux.org|mirrors.tuna.tsinghua.edu.cn|g" /etc/apk/repositories && \
apk add -U tzdata && \
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone && \
apk add -U -t xxbuild gcc g++ musl-dev
ADD requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt
RUN apk del xxbuild
ADD app.py /code/main.py
@sempr
sempr / docker_demo.go
Created July 17, 2019 03:13
Try Using Golang Docker API
package main
import (
"context"
"io"
"os"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/mount"
@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
@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 / 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"]