Skip to content

Instantly share code, notes, and snippets.

View caiguanhao's full-sized avatar
🇺🇦
#StandWithUkraine

CGH caiguanhao

🇺🇦
#StandWithUkraine
View GitHub Profile
@caiguanhao
caiguanhao / .gitignore
Created July 28, 2017 01:18
simple gitignore
# Node
npm-debug.log
# Mac
.DS_Store
# Windows
Thumbs.db
# vi
@caiguanhao
caiguanhao / .tmux.conf
Last active November 27, 2021 07:13
simple tmux conf
set -g mode-keys vi
bind-key -T copy-mode-vi 'v' send -X begin-selection
bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel
set -g base-index 1
set -g status on
set -g status-interval 5
set -g automatic-rename on
set -g automatic-rename-format '#{b:pane_current_path}'
@caiguanhao
caiguanhao / fake.sh
Created April 13, 2017 14:49
fake git commits
git log --reverse --pretty=format:"%at %s" | awk '{print "GIT_AUTHOR_DATE="$1" GIT_COMMITTER_DATE="$1" git commit --allow-empty -m \"" substr($0,12) "\""}'
@caiguanhao
caiguanhao / hyr.py
Created January 24, 2017 10:01
偷步进入确认出借页面
import subprocess
import json
class Injector:
KEY = '623739666634326663396430343561656433383332343361'
IV = '3234736464657873'
def __init__(self):
return
@caiguanhao
caiguanhao / hyr.sh
Last active January 12, 2017 06:35
shell script to buy HYR products (requires curl, jq, openssl)
#!/bin/bash
set -e
KEY=b79ff42fc9d045aed383243a
TOKEN_KEY=6y9d6e9332f5428e89d2f8c2
IV=24sddexs
PREFIX='{"app_version": "iPhone[10.2]", "app_from_type": "3", "app_version_mark": "3.1.0"'
USERAGENT='HengYiRong3.0/3.1.0.5 CFNetwork/808.2.16 Darwin/16.3.0'
@caiguanhao
caiguanhao / questions.md
Created August 26, 2016 09:56
Questions
  1. 给出任意多个有 5 个元素的数组,如 [[10, 32, 43, 11, 4], [7, 36, 44, 9, 4], ...],数组各项合计为 100 , 如何根据和指定数组 [1, 32, 48, 17, 2] 的相似度进行排序?最好是计算每项的相似分值,然后按分值排序。
def random_distribution(size = 5)
  a = []
  (size - 1).times do |i|
    s = a.inject(&:+) || 0
    a << rand(100-s)
 end
@caiguanhao
caiguanhao / ems.sh
Last active March 31, 2016 00:34
get notified every time ems info gets updated
while :; do \
export INFO="$(curl -s http://www.ems.com.cn/apple/query/EZ480728326CN | \
grep td-main | sed 's/<[^>]*>//g' | awk '{$1=$1}NF>1{print}' | tr -d '\r')"; \
test "$INFO" != "$LAST" && \
echo "$INFO" && echo "$INFO" | wechat-notify --raw oBjSswsfgSvA6FlrR0rszh5eThhI@CGH; \
export LAST="$INFO"; sleep 10; \
done
@caiguanhao
caiguanhao / iphone.sh
Last active March 24, 2016 07:41
iPhone on sale notification
while :; do \
curl -Ls 'http://www.apple.com/cn/shop/buy-iphone/iphone-se/64gb-金色' | \
grep -q '暂无供应' && \
sleep 10 || { \
printf 'iPhone is OK to buy right now' | \
wechat-notify --raw 'oBjSswsfgSvA6FlrR0rszh5eThhI@CGH' && \
break; \
}; done
@caiguanhao
caiguanhao / nspfm.rb
Created February 21, 2016 13:43
Make Non-Stop Pop FM mp3 files from YouTube
# This is a Ruby script to split the downloaded YouTube audio track into separate files
#
# 1. Download Non-Stop-Pop-FM.png from http://gta.wikia.com/wiki/File:Non-stop-pop.png
# 2. Download YouTube video "Non-Stop-Pop FM - GTA V Radio (Next-Gen)" using this command:
# youtube-dl -f 140 'https://www.youtube.com/watch?v=LGL50O1iBY0'
# 3. You may also need to increase the volume of original audio track:
# ffmpeg -i Non-Stop-Pop-FM.m4a -af 'volume=17.5dB' Non-Stop-Pop-FM.mp3
# 4. mkdir done
# 5. ruby nspfm.rb > nspfm.sh
# 6. bash nspfm.sh
@caiguanhao
caiguanhao / README.md
Last active December 4, 2016 05:38
generate flip rotate animation keyframes
@keyframes flip-rotate-5-3-60 {
  0%, 1.5% { margin-top: 60px; }
  1.5%, 19.7% { margin-top: 0px; }
  22.7%, 39.4% { margin-top: -60px; }
  42.4%, 59.1% { margin-top: -120px; }
  62.1%, 78.8% { margin-top: -180px; }
  81.8%, 98.5% { margin-top: -240px; }
  100% { margin-top: -300px; }
}