Posts

Showing posts from March, 2018

How to create an chrome extension

1. See the useless official document     https://developer.chrome.com/extensions/getstarted 2. See my codes     https://github.com/yingshaoxo/No_More_Chinese/tree/example-of-chrome-extension 3. Core question     + [Content scripts](https://developer.chrome.com/extensions/content_scripts) have only limited access to Chrome APIs. This access does not include the API you are trying to use (e.g. `chrome.tabs`). If you need to use that API, you will have to do so in a [background script](https://developer.chrome.com/extensions/background_pages).

Make a always running service in android based on kotlin

### 0. What is `service`? You could see `service` as a always running program But by default, a service runs in the same process as the main thread of the application Therefore, you need to use asynchronous processing in the service to perform resource intensive tasks in the background ___ ### 1. Basic idea or resources Official but you can't understand: [Google Developer Guide](https://developer.android.com/training/run-background-service/create-service.html) Unofficial but reachable: [tutorials_point](https://www.tutorialspoint.com/android/android_services.htm) ___ ### 2. Getting started + Create a kotlin file which names `MyService.kt`, and put the following codes in: ``` class MyService : Service() {     @Nullable     override fun onBind(intent: Intent): IBinder? {         return null     }     override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {         // Let it continue running until it is stopped.         Toast.makeText(this

Running Jupyter on server

#### 1. install ``` sudo -H pip install jupyter ``` #### 2. create config ``` jupyter notebook --generate-config ``` #### 3. set password ``` jupyter notebook password ``` #### 4. set ip ``` vim ~/.jupyter/jupyter_notebook_config.json ``` ``` {   "NotebookApp": {     "ip": "0.0.0.0",   } } ``` #### 5. run it ``` jupyter notebook ```

Master FFmpeg

#### I just want to see my beautiful face ``` ffplay -window_title "yingshaoxo" -vf hflip /dev/video0 ``` ___ #### Maybe record my screen with my voice ``` ffmpeg -y -f alsa -i hw:0 -f x11grab -framerate 30 -video_size 1920x1080 -i :0.0+0,0 -c:v libx264 -pix_fmt yuv420p -qp 0 -preset ultrafast ~/Videos/$(date +%F_%A_at_%H:%M:%S).mp4 ``` ___ #### You got it, I couldn't record without my beautiful face ``` ffmpeg -hide_banner -loglevel info -thread_queue_size 512 -y -f alsa -i hw:0 -thread_queue_size 512 -f x11grab -video_size 1920x1080 -i ":0.0" -thread_queue_size 512 -f v4l2 -video_size 320x240 -i "/dev/video0" -c:v libx264 -crf 30 -preset ultrafast -filter_complex 'overlay=main_w-overlay_w-10:main_h-overlay_h-10' -threads 0 ~/Videos/$(date +%F_%A_at_%H:%M:%S).mp4 ``` ___ #### Maybe do something to my face (camera) ``` ffmpeg -hide_banner -loglevel info -thread_queue_size 512 -y -f alsa -i hw:0 -itsoffset -1.266 -thread_queu

Best way to fix grub problem

Try the following ``` grub rescue > ls grub rescue > ls (hd0,msdos2) # let's assume this is the linux partition grub rescue > set root=(hd0,msdos2) grub rescue > set prefix=(hd0,msdos2)/boot/grub # or wherever grub is installed grub rescue > insmod normal # if this produced an error, reset root and prefix to something else .. grub rescue > normal ``` Run the following after you successfully boot ``` sudo update-grub sudo grub-install /dev/sdX # where /dev/sdX is your boot drive. ``` If you have to copy a whole linux system, you could use `Clonezilla` If you want to install multi-system at your machine, you have to make sure you are using grub boot. (There has two signal that shows you are in grub boot mode: 1. The quality of the boot GUI is very bad. 2. It has auto counting.)