$ gem install htmlentities
$ echo -n '测试文本' | ruby -r htmlentities -e "puts HTMLEntities.new.encode(STDIN.read, :decimal)"
测试文本
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Node | |
npm-debug.log | |
# Mac | |
.DS_Store | |
# Windows | |
Thumbs.db | |
# vi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) "\""}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import json | |
class Injector: | |
KEY = '623739666634326663396430343561656433383332343361' | |
IV = '3234736464657873' | |
def __init__(self): | |
return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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' |
- 给出任意多个有 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |