Skip to content

Instantly share code, notes, and snippets.

View hanxi's full-sized avatar
:octocat:
Happy Coding!!!

涵曦 hanxi

:octocat:
Happy Coding!!!
View GitHub Profile
@laixintao
laixintao / decent_request.py
Last active February 20, 2024 12:05
Send HTTP requests using python-requests with timeout, tcp reuse(session) and retry.
from requests.adapters import HTTPAdapter, Retry
from requests import Session
retries = Retry(
total=5, backoff_factor=1, status_forcelist=[502, 503, 504]
)
session = Session() # reuse tcp connection
session.mount("http://", HTTPAdapter(max_retries=retries))
session.mount("https://", HTTPAdapter(max_retries=retries))
@oofnikj
oofnikj / answerfile
Last active April 17, 2024 13:52
Install Docker on Termux
KEYMAPOPTS="us us"
HOSTNAMEOPTS="-n alpine"
INTERFACESOPTS="auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
hostname alpine
"
TIMEZONEOPTS="-z UTC"
@imba-tjd
imba-tjd / .Cloud.md
Last active April 18, 2024 03:22
☁️ 一些免费的云资源

IaaS指提供系统(可以自己选)或者储存空间之类的硬件,软件要自己手动装;PaaS提供语言环境和框架(可以自己选);SaaS只能使用开发好的软件(卖软件本身);BaaS一般类似于非关系数据库,但各家不通用,有时还有一些其它东西。

其他人的集合

@hanxi
hanxi / lru.lua
Last active November 30, 2018 05:31
用 Lua 实现 LRU
local lru = {}
local lru_mt = { __index = lru }
local function addnode(self, node)
local head = self._head
node._next = head
if head then
head._pre = node
end
self._head = node
@egorsmkv
egorsmkv / build-git.md
Last active May 5, 2023 04:19
Build git from source code on CentOS 7

Build git from source code

1) Go to https://git-scm.com/ and check out the latest version of Git

Currently, the latest version is 2.18.0. Download and extract it and go to the folder of the source code:

wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.18.0.tar.gz
tar xf git-2.18.0.tar.gz
cd git-2.18.0/
@gaoconghui
gaoconghui / pdf_tripper.py
Last active January 20, 2023 16:29
删除pdf中指定的字(如水印 版权标记)
# -*- coding: utf-8 -*-
"""
给定一个pdf路径,以及一个列表,可修改pdf内容,删除所有符合条件的文字。
"""
from PyPDF2 import PdfFileReader, PdfFileWriter
from PyPDF2.generic import TextStringObject, NameObject
from PyPDF2.pdf import ContentStream
from PyPDF2.utils import b_
@daurnimator
daurnimator / fengari-vue.lua
Last active June 17, 2021 11:43
Playing with Vue from fengari
-- Load Vue library
package.loadlib("https://cdn.jsdelivr.net/npm/vue@2.5.13/dist/vue.js", "*")
-- Get Object helper
local Object = dofile("https://gist.githubusercontent.com/daurnimator/5a7fa933e96e14333962093322e0ff95/raw/8c6968be0111c7becc485a692162ad100e87d9c7/Object.lua").Object
local myapp = js.new(js.global.Vue, Object{
el = "#foo";
template = [[
<div id="foo">{{message}}</div>
]];
@doitian
doitian / sx_syslog.c
Last active March 31, 2023 04:24
skynet syslog logger
/// 使用 syslog 作为日志后端,可替代默认的 logger.
//
// 配置
//
// logservice = "sx_syslog"
// logger = "skynet.server.20170924-a577f12.ci.1"
//
// logger 配置 ident 和 syslog 选项。Ident 必须是有效的文件名,不能包含 /[] 等特殊字符。
//
// 比如可以按照下面方案
local DIRSEP = package.config:sub(1, 1)
local function is_readable(filename)
local fd = io.open(filename, "r")
if fd then
fd:close()
return true
else
return false
end
@mdonkers
mdonkers / server.py
Last active April 17, 2024 07:40
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
License: MIT License
Copyright (c) 2023 Miel Donkers
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer