Skip to content

Instantly share code, notes, and snippets.

@zhangtaii
zhangtaii / adb_split_input.js
Last active March 3, 2021 17:11
adb_split_input.js
#!/usr/bin/env node
// usage: ./adb_input.js yourtext
const util = require('util');
const exec = util.promisify(require('child_process').exec);
async function execAsync(cmd) {
try {
@zhangtaii
zhangtaii / BuyButton.js.md
Last active March 2, 2021 16:36
BuyButton.js.md

NOTE:

Widnows WSL watchify 监听更新不工作是环境原因, Mac下无此问题, watchify 性能也是环境原因

  1. 修改 package.json src:watch脚本, 增加-d 使生成 buybutton.dev.js 包含 source maps; 修改产物路径解决 source maps 路径与实际文件路径不一致导致的 src 下断点不工作(unbound breakpoint)
  2. 修改 index.html 资源引用路径
--- a/package.json
+++ b/package.json
var fs = require("fs");
var path = require("path");
var inputFile = process.argv[2],
input = fs.readFileSync(inputFile, "utf8"),
start = input.indexOf("__d("),
end = input.indexOf("__r("),
code = input.substring(start, end);
byte[] hexStringToByteArray(String s) {
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}
{
"cuid": "9f7f2a47525300624901",
"data": {
"clientData": "eyJ0eXAiOiJuYXZpZ2F0b3IuaWQuZmluaXNoRW5yb2xsbWVudCIsImNoYWxsZW5nZSI6Ik15cFBZeURSNF9RSDlGNkVpU1I4Z1NWcTBkZ0pQR1drNTM0aU13dkhfZzQiLCJvcmlnaW4iOiJFVU5FWF9QQVkifQ==",
"registrationData": "BQSRalBa9V8hLm1DnyotA-Ym9yA6ctRDs98b2bbxhU2kVf2Jum2a9j-VAMPuhAXz4zXuyfngUGicFgvlru190Dq-QCEKU-bxv8yRdoCeB0fHOr9Y1B6khNxQYTvtDJu_SEFfcxp_LwCj3AVpNcl0p1oZ6nu8mXdIIJmtB_xXFEktdwwwggEdMIHDAgj4POOWfZt6qzAKBggqhkjOPQQDAjAXMRUwEwYDVQQDDAxHbnViYnkgUGlsb3QwHhcNMTkwMjI0MDMwNzAyWhcNMTkwMzA1MDg0NjM1WjAXMRUwEwYDVQQDDAxHbnViYnkgUGlsb3QwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATsSldyz8GZvnNat5FB6SxHb9bcB2DAPSCT0GJf_Yr3dTEhKE2yQaiymM9fj3mGRWqI4sCFR2STwokgLPJBBx77MAoGCCqGSM49BAMCA0kAMEYCIQD8TrGZ-APYgM4QwoX11OicvZqzPakftxHponLFe2ogiAIhAMF6kUvMOHsfiYBKp2yXxQiMBvwSVr1UjgdaHcS6xy8wMEYCIQD3AaFkm1QCmvFhzLNRs3AvjRPezw4LQA49B-q0uzj34QIhAO8bp8ZRkcAHAb860YUzCCgGANebFKhINHh6siPxDB6K"
}
}
@zhangtaii
zhangtaii / sublime regex replace
Created February 14, 2019 07:02
replace string sublime with regex group
Target content:
0x84
0xC
0x0
0x4C
Expeted result:
0x84
0x0C
0x00
00 A4 04 00 0C A0 00 00 06 17 00 4F 97 A2 E9 49 01 00
F0 01 00 00 80 30 82 01 3c 30 81 e4 a0 03 02 01 02 02 0a 47 90 12 80 00 11 55 95 73 52 30 0a 06 08 2a 86 48 ce 3d 04 03 02 30 17 31 15 30 13 06 03 55 04 03 13 0c 47 6e 75 62 62 79 20 50 69 6c 6f 74 30 1e 17 0d 31 32 30 38 31 34 31 38 32 39 33 32 5a 17 0d 31 33 30 38 31 34 31 38 32 39 33 32 5a 30 31 31 2f 30 2d 06 03 55 04 03 13 26 50 69 6c 6f 74 47 6e 75 62 62 79 2d 30 2e 34 2e 31 2d 34 37 39 30
F0 01 00 80 80 31 32 38 30 30 30 31 31 35 35 39 35 37 33 35 32 30 59 30 13 06 07 2a 86 48 ce 3d 02 01 06 08 2a 86 48 ce 3d 03 01 07 03 42 00 04 8d 61 7e 65 c9 50 8e 64 bc c5 67 3a c8 2a 67 99 da 3c 14 46 68 2c 25 8c 46 3f ff df 58 df d2 fa 3e 6c 37 8b 53 d7 95 c4 a4 df fb 41 99 ed d7 86 2f 23 ab af 02 03 b4 b8 91 1b a0 56 99 94 e1 01 30 0a 06 08 2a 86 48 ce 3d 04 03 02 03 47 00 30 44 02 20 60 cd
F0 01 01 00 40 b6 06 1e 9c 22 26 2d 1a ac 1d 96 d8 c7 08 29 b2 36 65 31 dd a2 68 83 2c b8 36 bc d3 0d fa 02 20 63 1b 14 59 f0 9e 63 30 05 57 22 c8 d8 9b 7f 48 88 3b 90 89
@zhangtaii
zhangtaii / azure-pipelines.yml
Last active February 24, 2021 22:41
Setup Azure Pipelines for React Native
trigger:
branches:
include:
- master
- releases/*
exclude:
- refs/tag/*
pool:
@zhangtaii
zhangtaii / Podfile
Created November 25, 2018 16:17
Add launchPackager shell script to React Native with CocoaPods
# The target name is most likely the name of your project.
target 'NumberTileGame' do
# Your 'node_modules' directory is probably in the root of your project,
# but if not, adjust the `:path` accordingly
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'CxxBridge', # Include this for RN >= 0.47
'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
'RCTText',
@zhangtaii
zhangtaii / renameCH2Pinyin.py
Created November 19, 2018 08:28
To rename Unicode Chinese character file names to Pinyin
#!/usr/bin/python
# renameCH2Pinyin.py
# Rename filename from Chinese characters to capitalized pinyin using the
# mapping file and taking out the tone numbers
# 批量更改文件名, 中文 -> 拼音, 原gist: https://gist.github.com/hxinblog/5001033
# 使用参考: http://sunzhen.blogspot.com/2016/05/rename-chinese-filenames-to-pinyin.html
# Origin gist link, which is broken: https://gist.github.com/hxinblog/5001033,