Skip to content

Instantly share code, notes, and snippets.

View hangj's full-sized avatar
🥏
happy coding

hangj hangj

🥏
happy coding
View GitHub Profile
@hangj
hangj / runOrReloadOpenresty.sh
Last active September 16, 2019 07:13
run/reload openresty
#!/usr/bin/bash
cd ~/work/ || exit
sudo openresty -p `pwd` -c conf/nginx.conf -t || exit
ps -ef | grep openresty | grep -v grep
if [ $? -eq 0 ]
then
@hangj
hangj / deploy.lua
Last active September 20, 2019 15:12 — forked from samael500/handler.lua
Validating payloads from GitHub webhooks with Nginx + Lua
-- $ sudo opm get jkeys089/lua-resty-hmac
local shell = require "resty.shell"
local cjson = require "cjson.safe"
local hmac = require "resty.hmac"
local secret = '<MY SUPER SECRET>'
local event = 'push'
local branch = 'refs/heads/master'
@hangj
hangj / myredis.lua
Created September 24, 2019 12:15
a little wrapper for lua-resty-redis.lua
local redis = require "resty.redis"
local M = {}
local function set_keepalive(p, red, opts)
while true do
if 'dead' == coroutine.status(p) then
break
end
@hangj
hangj / exif.js
Last active October 8, 2022 08:55
exif.js for miniprogram 小程序获取照片exif元信息
(function() {
// https://github.com/exif-js/exif-js
var debug = false;
var root = this;
var self = window || this;
var Blob = Blob || function () {}
var DOMParser = DOMParser || function () {}
var EXIF = function(obj) {
@hangj
hangj / fuckgfw.sh
Last active December 3, 2019 06:01
backup proxy solution
#!/usr/bin/env bash
# https://www.cnblogs.com/hangj/p/11838259.html
IP=localhost
FILE=proxy.pac
# 找到一个可用的 port
SOCKSPORT=`python -c 'import socket; s=socket.socket(); s.bind(("localhost", 0)); print(s.getsockname()[1]); s.close()'`
HTTPPORT=`python -c 'import socket; s=socket.socket(); s.bind(("localhost", 0)); print(s.getsockname()[1]); s.close()'`
@hangj
hangj / windowsVolumeAdjust.py
Last active July 6, 2021 08:11
python 调节 Windows 系统音量
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# pip3 install pycaw -i https://pypi.douban.com/simple
# https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-getvolumerange
from ctypes import cast, POINTER
from comtypes import CLSCTX_ALL
from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume
@hangj
hangj / inject.lua
Last active February 8, 2022 06:16
local function run(src, level)
local level = level or 1
level = level + 3
assert(level >= 3)
local function get(t, k)
-- print('get:', k)
-- print('bt:', debug.traceback())
local level = level + 1
@hangj
hangj / vps_setup.sh
Last active September 2, 2022 07:40
setup shadowsocks server for my vps
#!/usr/bin/env bash
# change the working directory to where this file is located
full_file_path=`realpath $0`
absolute_dir=`dirname $full_file_path`
cd $absolute_dir
# crate new user if not exists
username="bot"
userpassword="password123456"
Readme: In the following pseudo code, [] indicates a subroutine.
Sometimes I choose to write the subroutine inline under the [] in order to maintain context.
One important fact about the way rollbacks are handled here is that we are storing state for every frame.
In any real implementation you only need to store one game state at a time. Storing a game
state for every frame allows us to only rollback to the first frame where the predicted inputs don't match the true ones.
==Constants==
MAX_ROLLBACK_FRAMES := Any Positive Integer # Specifies the maximum number of frames that can be resimulated
FRAME_ADVANTAGE_LIMIT := Any Positive Integer # Specifies the number of frames the local client can progress ahead of the remote client before time synchronizing.
@hangj
hangj / s3_upload_file.sh
Created November 24, 2022 07:07
s3 upload files with shell script
#!/usr/bin/env bash
# hangj.cnblogs.com
# https://www.cnblogs.com/hangj/p/16921863.html
s3_key="Q3AM3UQ867SPQQA43P2F"
s3_secret="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"
session_token="Security-Token"
bucket="bucket-log"