Posts

Showing posts from January, 2018

Can't import or play gnome recorded video in Windows System?

`ffmpeg -i in.mp4 -crf 18 -pix_fmt yuv420p -c:a copy out.mp4`

How to gain permission and delay for user clicking in Kotlin

1. 绑定一个按钮事件: `button.setOnClickListener({ view -> doSomething() })` 2. 申请一个权限并 delay waiting for user ``` // get permission // import android.Manifest if (ContextCompat.checkSelfPermission(this,                 Manifest.permission.WRITE_EXTERNAL_STORAGE)         != PackageManager.PERMISSION_GRANTED) {     ActivityCompat.requestPermissions(this,             arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), 999)     Thread.sleep(7 * 1000) } ```

How to set global variable in Kotlin

1. put this on top: ``` object GlobalVariable {     var mp = MediaPlayer() } ``` 2. use it everywhere `GlobalVariable.mp` 3. so you won't have to worry about open too many MediaPlayer at the same time

Review in 2017 and Plans for 2018

Have Done in 2017:  At least solve 100 algorithm problems on leetcode during this year Insist learning on Khan Academy Learn JavaScript for web app design Maintain GitHub project with Vim Solving at least 1 math question per few days Learning New Concept English 4th book Know how to break through the school net Master Linux System like Kali, Ubuntu Master System Installation, including Android, Linux, Windows Plan to do: Use Javascript Use Python3 Use Kotlin Use Golang or C Keep interests in Programming, be happy, don’t mind other’s judgment. ​

Fail to run emulator in Android Studio and Kali System(rolling) with hardware graphics?

``` cd Android/Sdk/emulator/lib64/libstdc++ mv libstdc++.so.6 libstdc++.so.6.bak ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 ```

How to install and use jedi-vim in Kali System

##### 1. Remove old Vim first `apt purge vim*` #### 2. Install essential python relyings `apt install python3 python3-dev` #### 3. Pull jedi-vim to local ``` mkdir ~/.vim cd ~/.vim rm * -fr git clone https://github.com/davidhalter/jedi-vim.git . ``` #### 4. Install a new Vim version for python support `apt install vim-nox`

Master System Installation

##### 修复多系统如 win10 的引导: 0. 主板设置为启动全基于 `BIOS` 1. PE 用 `DISM++` 恢复某个盘的 win10 引导 2. 去那个 win10 玩玩`EasyBCD`也可以 3. 去你安装好的另一个盘的linux,用 `update-grub` ___ #### kali 才是人用的系统 ###### 修复显卡太高级灰屏的问题(如 NVIDIA) 1. `Ctrl+Alt+F1` to terminal 2. `apt-get install lightdm` (choice lightdm) 3. `reboot` ###### 修复  `shutdown now` or `reboot` 卡机的问题 `apt-get update && apt-get dist-upgrade` https://thehacktoday.com/installing-nvidia-driver-and-fix-boot-loading-and-freezing-issue-in-kali-linux/

Keep python script running by systemd service

#### 0. write a python script `vim time_logger.py` ``` import os import logging import time current_dir = os.path.abspath(os.path.dirname(__file__)) logging.basicConfig(filename=os.path.join(current_dir, 'whatsup.log'), level=logging.INFO) now = time.strftime("%H:%M:%S") logging.info(now + '\n') time.sleep(3) ``` #### 1. create a service file `vim  /lib/systemd/system/my_python@your_user_name.service` ``` [Unit] Description=My first python service After=multi-user.target [Service] Type=idle ExecStart=/usr/bin/python /root/Codes/Python/time_logger.py Restart=always #RestartSec=1 [Install] WantedBy=multi-user.target ``` #### 2. reload deamon and enable our service `systemctl daemon-reload` `systemctl enable my_python@your_user_name.service` #### 3. reboot and check `reboot` go to the python script folder and run `cat whatsup.log` constantly, you will see current time logging. #### 4. links may help: https://

Use Chrome on Kali System

## Forget about those tutorials, just follow me. #### 1. download chrome deb file from whatever place #### 2. install chrome `dpkg -i google-chrome-stable_current_amd64.deb` `apt install -f` `dpkg -i google-chrome-stable_current_amd64.deb` #### 3. allow root user to run chrome `vim /opt/google/chrome/google-chrome` change the last line to `exec -a "$0" "$HERE/chrome" "$@" --no-sandbox --user-data-dir` #### 4. just click chrome icon, then enjoy it.