Skip to content

Instantly share code, notes, and snippets.

View pexcn's full-sized avatar
🇹🇼

Sing Yu Chan pexcn

🇹🇼
  • Earth ⇄ Venus
  • Cantonia, West Taiwan
View GitHub Profile
@pexcn
pexcn / patch-rtc.py
Last active September 15, 2015 09:49 — forked from Lekensteyn/patch-rtc.py
Script to patch an Android recovery.img file, changing the qcom,qpnp-rtc-write Device Tree property (tested with an Android 5.1 image based on kernel 3.4 for a Nexus 5 (rev_11)).
#!/usr/bin/env python
"""
Patch a recovery image to enable RTC writing
Unfortunately it has not the intended effect (tested from recovery):
~ # /system/xbin/hwclock -w
hwclock: RTC_SET_TIME: Operation not permitted
<3>[ 25.821247] spmi_pmic_arb fc4cf000.qcom,spmi: pmic_arb_wait_for_done: transaction denied (0x5)
<3>[ 25.821338] qcom,qpnp-rtc qpnp-rtc-ee162000: SPMI write failed

ChinaDNS

Deprecated

git clone https://github.com/pexcn/ChinaDNS.git && pushd ChinaDNS
./autogen.sh
CFLAGS="-O3 -ffast-math" ./configure --enable-static
make
strip src/chinadns.exe
popd
@pexcn
pexcn / ChinaDNS Flow.md
Last active February 6, 2023 03:03
记录一下 ChinaDNS 的工作原理和一些 DNS 相关的想法

ChinaDNS 的工作流程

ChinaDNS 的上游 DNS 分为 国内 DNS可信 DNS

工作流程

  1. ChinaDNS 会同时向上游的 DNS 发送请求。
  2. 如果 可信 DNS 先返回,则直接采用 可信 DNS 的结果。
  3. 如果 国内 DNS 先返回,分两种情况:如果返回的结果是国内的 IP, 则采用;否则丢弃并转而采用 可信 DNS 的结果。
@pexcn
pexcn / auto-sign.sh
Created March 4, 2018 11:54
china unicom mobile client auto sign script
#!/bin/bash -xe
# Replace ******** with your token
export SIGN_IN_URL=http://m.client.10010.com/SigninApp/signin/querySigninActivity.htm?token=********
export DAY_SIGN_URL=http://m.client.10010.com/SigninApp/signin/daySign.do
export SCRIPT_PATH=$(dirname $0)
echo "$(date +'%Y-%m-%d %T')" >> $SCRIPT_PATH/log.txt
curl $SIGN_IN_URL \
@pexcn
pexcn / java_extract.bat
Created September 5, 2018 13:31 — forked from milolav/java_extract.bat
Batch file to extract portable version of java jre or jdk from installer
@echo off
rem Batch file that extracts java from installer
rem Original topic on stackoverflow:
rem http://stackoverflow.com/questions/1619662/how-can-i-get-the-latest-jre-jdk-as-a-zip-file-rather-than-exe-or-msi-installe
setlocal
if [%1]==[] goto usage
set fn=%~n1
7z.exe e %1 .rsrc\1033\JAVA_CAB10\111
if errorlevel 1 goto err
@pexcn
pexcn / hh_repart
Last active July 5, 2022 09:53
System partition resize script for Nexus 5.
#!/sbin/sh
#
# Copyright (C) 2018 Unlegacy Android Project
# Copyright (C) 2018 Svyatoslav Ryhel
# Copyright (C) 2019 Nick80835
# Copyright (C) 2019 z3dd3r
#
# Made for Hammerhead
#

SDCard Write Speed Test

# 64k
dd if=/dev/zero of=test bs=64k count=1638 && rm -f test
dd if=/dev/zero of=test bs=64k count=1638 conv=fdatasync && rm -f test
dd if=/dev/zero of=test bs=64k count=1638 conv=fsync && rm -f test
dd if=/dev/zero of=test bs=64k count=1638 oflag=dsync && rm -f test
# 1024k
dd if=/dev/zero of=test bs=1024k count=100 &amp;&amp; rm -f test

https://www.google.com/android/uncertified

# disable root at first.

# backup
adb shell sqlite3 /data/data/com.google.android.gsf/databases/gservices.db \"select * from main where name='android_id'\"
# update
adb shell sqlite3 /data/data/com.google.android.gsf/databases/gservices.db \"update main set value='<my_certified_android_id>' where name='android_id'\"
# check
@pexcn
pexcn / dump_art_partition.md
Last active February 25, 2022 18:03
dump atheros art partition from full firmware.
# 4MB
# art: 0x003F0000-0x00400000, 65536 bytes
dd if=full.bin of=art.bin bs=1 count=65536 skip=4128768

# 8MB
# art: 0x007F0000-0x00800000, 65536 bytes
dd if=full.bin of=art.bin bs=1 count=65536 skip=8323072

# 16MB
# unpack
bsdcpio -id < ../extra.lzma

# repack
find . | cpio -o --format='newc' --owner root:root | lzma > ../extra.lzma