Xiaomi

Xiaomi 刷系统。

小米 Note:

http://www.miui.com/thread-18831512-1-1.html

如何线刷:

http://www.miui.com/shuaji-393.html

线刷工具选项错误:

http://bbs.xiaomi.cn/t-13302104

Google 全家桶:

https://opengapps.org/app/

如何选择不同的 suite:

https://github.com/opengapps/opengapps/wiki/Package-Comparison

结论:mini 是最合适的。

安装 Google 全家桶后闪退。查看 log:

1
adb logcat *:E
1
2
3
4
5
6
03-14 15:56:16.090 20886 20886 E WebViewFactory: Chromium WebView package does not exist
03-14 15:56:16.090 20886 20886 E WebViewFactory: android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed

03-14 15:56:16.177 20886 20886 E DeviceDoctorHandler: FATAL EXCEPTION: main
03-14 15:56:16.177 20886 20886 E DeviceDoctorHandler: Process: com.google.android.gms.ui, PID: 20886
03-14 15:56:16.177 20886 20886 E DeviceDoctorHandler: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.android.gms/com.google.android.gms.auth.uiflows.minutemaid.MinuteMaidActivity}: android.util.AndroidRuntimeException: android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed

所以就是 WebView 的问题,然后参考这个:

https://www.quora.com/How-do-I-enable-Android-system-web-view-in-Android-7

顺便回答了这个问题:

https://www.zhihu.com/question/63714089

输入法设置也闪退:

1
2
3
03-14 19:29:40.418 16063 16063 E AndroidRuntime: FATAL EXCEPTION: main
03-14 19:29:40.418 16063 16063 E AndroidRuntime: Process: com.android.inputmethod.latin, PID: 16063
03-14 19:29:40.418 16063 16063 E AndroidRuntime: java.lang.RuntimeException: Unable to resume activity {com.android.inputmethod.latin/com.google.android.apps.inputmethod.latin.preference.SettingsActivity}: java.lang.RuntimeException: Preference xml file not specified

https://github.com/opengapps/aosp_build/issues/116

说什么清了 data 然后重装 GBoard.

1
2
adb shell ls -lR | grep inputmethod
adb shell ls -lR | grep LatinIMEGooglePrebuilt

查看包名:

https://stackoverflow.com/questions/6289149/read-the-package-name-of-an-android-apk

1
adb shell "pm list packages -f"

重装:

https://stackoverflow.com/questions/12483720/adb-how-to-reinstall-an-app-without-retaining-the-data

1
2
adb uninstall com.android.inputmethod.latin
adb install -r GBoard.apk
1
2
adb shell pm clear com.android.inputmethod.latin
adb install -r GBoard.apk

好的上面这两个都是不行的。看来目前就只能 wipe data 然后重装。

DiskPart

Basic usage of diskpart on windows.

EFI

http://linuxbsdos.com/2015/09/05/how-to-delete-grub-files-from-a-boot-efi-partition-in-windows-10/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
% These commands are used to identify and select the hard drive

diskpart

list disk

sel disk

% These commands are used to list the partitions, select the Boot EFI partition,
% then assign it a drive letter

list vol

sel vol 2

assign letter=D:

exit

% These commands are used to change into the Boot EFI folder and delete the GRUB folder

cd /d D:

ls

ls EFI

cd EFI

ls

rmdir /s ubuntu
1
2
3
4
5
diskpart
select disk 0
select partition 3
delete partition override
exit

Windows

Windows 查看磁盘分区格式

  1. 按下 Win+R 打开运行,输入 cmd,打开命令提示符;
  2. 输入 diskpart 按回车执行,切换到 DISKPART 命令,输入list disk,按回车;
  3. 查看最后一列的GPT,如果有*号则为GPT,如果没有则为MBR。

Nexus6P

Nexus 6P 刷系统。

Windows 10 自带开启热点功能,搜索 hotspot.

https://withdewhua.space/2018/10/13/http-proxy-share/#windows

然后设置 shadowsocks 允许 LAN 代理:Allow Clients from LAN

在 Nexus 6P 启动界面配置代理手动:

1
2
3
4
5
6
7
8
9
ipconfig

Wireless LAN adapter Local Area Connection* 15:

Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::99f2:dfc9:5e94:373c%27
IPv4 Address. . . . . . . . . . . : 192.168.137.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :

解锁 Nexus 6P:

http://www.mk52.cn/jiaocheng/1324.html

1
2
3
4
adb reboot bootloader
fastboot devices
fastboot flashing unlock
fastboot reboot

如何进入 recovery mode:

http://www.mk52.cn/jiaocheng/1335.html

修复教程:

https://www.xda-developers.com/nexus-6p-bootloop-fix/

https://forum.xda-developers.com/nexus-6p/general/guide-fix-nexus-6p-bootloop-death-blod-t3640279

1
2
fastboot devices
fastboot flash boot N2G48B_4Cores.img

现在问题变成了一直卡在开机 logo 界面(相对于无限重启)。

https://blog.csdn.net/anod/article/details/84297347

刷入对应版本 (N2G48B) 的 OTA:

https://developers.google.com/android/ota

https://dl.google.com/dl/android/aosp/angler-ota-n2g48b-8166f6bf.zip

1
2
adb devices
adb sideload angler-ota-n2g48b-*.zip

或许直接看这个:

https://forum.xda-developers.com/nexus-6p/help/help-unbricking-nexus-6p-t3382895

和上面一样,报错:

1
This package is for "angler" devices; this is a "".

原因在这里:

https://www.securitynewspaper.com/2017/05/12/oneplus-otas-analysis-exploitation/

或者这里:

https://drive.google.com/file/d/0Bz6x7k-VkpUJRjl6WjRhVmdXU0E/view

You are now on the Android Recovery screen. On the third line at the top of the screen you
will see something that looks like this:
6.0.1 / MOB30I / 2756745
The middle one is your current Build Number. Make note of this as the Rescue OTA you
need corresponds to this one or a more recent one. (NOTE: You cannot install an older one
than your current Build Number.)

总算是把 boot.img 恢复了,还是送到淘宝店家去修吧。

Ubuntu Service Management

Service/Job management on Ubuntu.

supervisor

  • reread - Reread supervisor configuration. Do not update or restart the running services.
  • update - Restart service(s) whose configuration has changed. Usually run after ‘reread’.
  • reload - Reread supervisor configuration, reload supervisord and supervisorctl
  • restart - Restart service(s)

service

1
2
3
4
service ssh status
service ssh restart

netstat –nlp | grep 22

tee

1
tee 

In computing, tee is a command in command-line interpreters (shells) using standard streams which reads standard input and writes it to both standard output and one or more files, effectively duplicating its input.

WeChat

将 Android 上微信的聊天记录导出为 txt.

主要参考这两篇文章:


不需要做的事情大概有这样几点:

  • 不需要将手机 root
  • 不需要使用 Android Studio
  • 不需要使用 re 管理器
  • 不需要修改安卓虚拟机的 IMEI 码

需要做的事情整个步骤如下所述:


如果我们已经有手机的 root 权限,那我们可以直接在手机连接至计算机的情况下使用 adb 来将 /data/data/com.tencent.mm/MicroMsg 的某个 md5 子目录下的 EnMicroMsg.db 拷贝至计算机。

1
2
3
adb devices
adb shell
adb pull /data/data/com.tencent.mm/MicroMsg/xxxx/EnMicroMsg.db .

使用 adb devices 确认 adb 能够发现我们的手机,

adb shell 可以在交互式命令行下找到文件的具体位置,

然后使用 adb pull 来将对应位置处的文件从手机拷贝至计算机。


但是大概率我们是没有对手机做过 root 操作的,

除了冒险 root 手机之外我们还有其他的方法,那就是使用安卓模拟器。

这里我们使用 Genymotion. 下载安装并运行 Genymotion,并创建与手机型号一致的虚拟机。

因为虚拟机和真机的架构有点不同,为了安装微信 apk,我们需要下载与虚拟机相应版本的 ARM_Translation ,并拖拽至运行中的虚拟机进行安装。

把微信官网的 apk 拖拽至运行中的虚拟器中进行安装,这样有 root 权限的虚拟机上就可以运行微信了。


我们将手机上目标用户的微信聊天记录备份至计算机,然后在虚拟机上登录微信,并将聊天记录备份进行同步。

注意虽然聊天记录备份也是后缀为 .db 的文件 Backup.db,但是我们无法用相同的方式打开查看。

现在我们使用 adb 将 /data/data/com.tencent.mm/MicroMsg/ 处的 EnMicroMsg.db 文件拷贝至计算机。

这是一个加密的 SQLite 文件。


接下来我们使用 sqlcipher.exe 打开此数据库文件,但是需要输入相应的密码。

sqlcipher.exe 可以在这里下载:

密码的计算方式需要查看手机的IMEI 和 微信的 uid。

微信的 uid 通过 chrome 自带插件查看网页微信使用中产生的 Log:chrome://net-internals/#events

而手机的 IMEI 可以通过在拨号键盘上输入: *#06#

最后将 IMEI 和 uid 进行拼接,并做MD5计算:http://tool.chinaz.com/tools/md5.aspx

在计算时使用 32位[小] 选项,取计算结果的前7位即是数据库文件密码。


至此,我们就可以愉快地查看数据库内容啦。

message 表里数据导出为 csv 就可以愉快地做数据分析了。

xnheulpb

http://www.flypy.com/bbs/forum.php?mod=viewthread&tid=166

xnheulpb.reg

1
2
3
4
5
6
7
8
9
10
11
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\InputMethod\Settings\CHS]
"LangBar Force On"=dword:00000000
"Enable Double Pinyin"=dword:00000001
"EmoticonTipTriggerCount"=dword:00000001
"HapLastDownloadTime"=hex(b):eb,69,29,59,00,00,00,00
"UserDefinedDoublePinyinScheme0"="FlyPY*2*^*iuvdjhcwfg xmlnpbksqszxkrltvyovt"
"DoublePinyinScheme"=dword:0000000a
"UDLLastUpdatedTime"="2017-05-27 22:01:40"
"UDLCount"=dword:0000018b
"UDLVisibleCount"=dword:0000018b

LaTeX

Basic usage of LaTeX.

todo

1
2
3
\usepackage[colorinlistoftodos]{todonotes}

\todo[inline, color=green!40]{This is an inline comment.}

enumitem

1
2
3
4
5
6
7
\usepackage{enumitem}

\maketitle
\begin{enumerate}[label=(\alph*)]
\item an apple
\item a banana
\end{enumerate}

verb

1
\verb|.bib|

href

1
\href{https://www.overleaf.com/blog/184}{Mendeley}

equiv

1
a\equiv b \bmod p

matrix

1
x^{(1)}=\begin{bmatrix}\frac{3}{2}\\[0.3em]\frac{9}{4}\end{bmatrix}, 

Just use overleaf here.

jumpnav-main

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
\documentclass[chi_draft]{sigchi}
\begin{document}
%\usepackage{natbib}

\title{}
\author{}

\maketitle

\input{abstract}


\input{intro}
\input{related}
\input{data}
\input{problem}
\input{observations}
\input{approach}
\input{exp}
\input{conclusion}

\bibliographystyle{SIGCHI-Reference-Format}
\bibliography{references}

\end{document}

convex optimization

1
2
3
4
5
6
7
\begin{alignat*}{2}
\min\quad & -2x_1-x_2+x_3 \\
\mbox{s.t.}\quad
&x_1+x_2+2x_3 \le 6 \\
&x_1+4x_2-x_3 \le 4 \\
&x_1, x_2, x_3 \ge 0
\end{alignat*}

MISC

1
2
3
4
5
6
7
8
9
10
11
\noindent
\textbf{}
\LaTeX{}
\TeX\
\TeX{}
\textbackslash
\textit{}
\empha{}
{\bf }
\smallskip
\bigskip

tikz

here

1
2
3
4
5
6
7
8
9
10
11
\begin{center}
\begin{tikzpicture}[domain=0:0.5,xscale=13,yscale=3.8]
\draw[<->] (0,2) node[left]{EUR}-- (0,0) -- (.7,0) node[below] {$q$};
\draw[red] plot (\x, {0.25+\x/2+\x*\x/2}) node[right] {$v_1(x)$};
\draw[green] plot (\x, {0.025+\x+\x*\x}) node[right] {$v_2(x)$};
\draw[thin, dashed] plot (\x, {0.275+1.5*\x+1.5*\x*\x}) ;
\draw[thick,domain=0:0.33666] plot (\x, {0.05+2*\x+2*\x*\x}) ;
\draw[thick,domain=0.33666:0.5]
plot (\x, {0.5+\x+\x*\x}) node[right] {$2\min[v_1,v_2]$};
\end{tikzpicture}
\end{center}

tabular*

table.

1
2
3
4
5
6
7
\begin{tabular*}{0.75\textwidth}{@{\extracolsep{\fill} } | c | c | c | r | }
\hline
label 1 & label 2 & label 3 & label 4 \\
\hline
item 1 & item 2 & item 3 & item 4 \\
\hline
\end{tabular*}

multirow

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
\begin{table}
\caption{Statistics of the Dataset}
\label{tab:dataset}
\centering
\begin{tabular}{c|c|c|c}
\hline \hline
\multirow{3}{*}{Science} & \multirow{2}{*}{Video} & Count & \\ \cline{3-4}
& & Avg. length & \\ \cline{2-4}
& User & Count & \\ \cline{2-4}
& \multirow{3}{*}{Back-jumps} & Count & \\ \cline{3-4}
& & Max back-jumps/video & \\ \cline{3-4}
& & Min back-jumps/video & \\ \cline{2-4}
\hline \hline
\end{tabular}
\end{table}
}

caption

1
2
\usepackage{caption} 
\captionsetup[table]{skip=10pt}

pdflatex

1
2
3
4
5
6
\documentclass{article}

\begin{document}
First document. This is a simple example, with no
extra parameters or packages included. \cite{knuthwebsite}.
\end{document}
1
2
sudo apt-get install texlive
pdftex /path/to/myfile.tex

bibtex

article.tex

1
2
3
4
5
6
7
8
9
10
\documentclass{article}
\usepackage{natbib}

\begin{document}
First document. This is a simple example, with no
extra parameters or packages included. \cite{knuthwebsite}.

\bibliographystyle{alpha}
\bibliography{article}
\end{document}

article.bib

1
2
3
4
5
@misc{knuthwebsite,
author = "Donald Knuth",
title = "Knuth: Computers and Typesetting",
url = "http://www-cs-faculty.stanford.edu/\~{}uno/abcde.html"
}

Suppose you have article.tex and article.bib. You need to run:

  • latex article.tex (this will generate a document with question marks in place of unknown references)
  • bibtex article (this will parse all the .bib files that were included in the article and generate metainformation regarding references)
  • latex article.tex (this will generate document with all the references in the correct places)
  • latex article.tex (just in case if adding references broke page numbering somewhere)

Just add the following line to your ~/.bashrc file (modify the main keyword accordingly to the name of your .tex and .bib files)

1
alias texbib='pdflatex main.tex && bibtex main && pdflatex main.tex && pdflatex main.tex && gnome-open main.pdf'

xelatex

需要用 xecjkzhspacing 设置中文字体。 XeTex 缺省设了英文字体 Latin Modern,所以你能看到英文字。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
\documentclass{article}
\usepackage{xeCJK}

\setCJKmainfont{simsun.ttf}
\setCJKsansfont{simhei.ttf}
\setCJKmonofont{simfang.ttf}

\begin{document}

\title{作业}
\author{宋正阳}
\date{\today}

\maketitle

\end{document}

font

1
Fontconfig warning: "/etc/fonts/conf.d/65-droid-sans-fonts.conf", line 96: Having multiple values in <test> isn't supported and may not work as expected
1
2
3
4
5
6
7
8
9
10
11
12
13
sudo apt install --reinstall fontconfig

<test name="lang">
<string>zh-cn</string>
<string>zh-sg</string>
<string>zh-hk</string>
<string>zh-tw</string>
<string>zh</string>
</test>

<test name="lang">
<string>zh-cn</string>
</test>

Tencent SNG

腾讯 SNG 校招面试分享。

  • 项目中的有趣点或难点
  • xgboost 和 lr 的优缺点
  • C++ 虚函数的实现
  • 线程和进程的区别
  • 在模型中哪些 feature 最有用
  • 算法题:将 1 到 m*n 按照螺旋方式填满 m * n 的矩阵。

Google

Google 暑期实习电话面算法题。

Phone Interview

Compare keyboard events sequences

1
2
# abc123\b123\b  -> abc1212
# abc1212 -> abc1212

Time O(n), Space O(n)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
def convert(s):
res = []
index = 0
for i in range(len(s)):
# abc12123
if s[i] != '\b':
if len(res) == index:
res.append(s[i])
else:
res[index] = s[i]
index += 1
else:
if index == 0:
continue
else:
index -= 1
return ''.join(res[:index])

def compare(s1, s2):
return convert(s1) == convert(s2)

Time O(n), Space O(1)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
def get_char(s, p):
cnt = 0
while p >= 0 and (cnt > 0 or s[p] == '\b'):
if s[p] == '\b':
cnt += 1
else:
cnt -= 1
p -= 1
return p

def compare_(s1, s2):
p1 = len(s1) - 1
p2 = len(s2) - 1

while p1 >= 0 and p2 >= 0:
p1 = get_char(s1, p1)
p2 = get_char(s2, p2)

if p1 >= 0 and p2 >= 0:
if s1[p1] != s2[p2]:
return False
else:
p1 -= 1
p2 -= 1

p1 = get_char(s1, p1)
p2 = get_char(s2, p2)
return p1 < 0 and p2 < 0
  • 能抽象就抽象。多写几个函数。

Test Case

1
2
3
4
5
6
assert(compare_('', '2\b') == True)
assert(compare_('', '12\b') == False)
assert(compare_('1', '12\b') == True)
assert(compare_('', '\b2\b') == True)
assert(compare_('', '12\b2\b') == False)
assert(compare_('1', '123\b2\b\b') == True)