Posts

Showing posts with the label Others

How to use USB (PE) operation system in virtualbox as vmdk image file

``` # Check usb id sudo fdisk -l # Create vmdk file from usb sudo vboxmanage internalcommands createrawvmdk -filename ~/UsbDisk.vmdk -rawdisk /dev/sdc # Change file permissions sudo chown $USER:$USER ~/UsbDisk.vmdk sudo usermod -a -G vboxusers $USER # Reboot sudo reboot # Add vmdk storage to storage controller. https://www.beizigen.com/post/virtualbox-under-ubuntu-starts-from-usb-flash-drive/ ```

How to force delete a file in git history

Suppose that .DS_Store is the file you wanted to delete. You do the following:  brew install bfg bfg --delete-files ".DS_Store" --no-blob-protection git reflog expire --expire=now --all && git gc --prune=now --aggressive git push origin --force ​

How to fold or unfold the vscode code blocks

select a bunch of codes (depends on your needs command+shift+p to open the shell, type fold level 1 after that, unfold if you want  ​

How to use regular expression to find repeated string in a text

For String \b(\w+)\s+\1\b (\w+)\1{1} For Number  ([0-9]+)+\1 (\d+)+\1 (?P<repeated>\d+)+\k<repeated>{2} or (?P<repeated>\d+)+\g{repeated}{2} References https://www.regular-expressions.info/backref.html http://www.blackwasp.co.uk/RegexBackreferences.aspx https://www.regular-expressions.info/refquick.html ​

How to screenshot with selected area by shortcuts in Gnome

shift + ctrl + PrtSc It'll save that picture at your clipboard.

Get started with MongoDB with Python

1. Install it https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/#install-mongodb-community-edition 2. Use it https://api.mongodb.com/python/current/tutorial.html 3. For Python ``` from pymongo import MongoClient import datetime import pprint client = MongoClient('mongodb://localhost:27017/') db = client.test_database posts = db.posts posts.delete_many({}) post = {     "author": "Mike",     "text": "My first blog post!",     "tags": ["mongodb", "python", "pymongo"],     "date": datetime.datetime.utcnow() } post2 = {     "author": "yingshaoxo",     "text": "My first latex book!",     "tags": ["mongodb", "python", "pymongo", "latex"],     # "date": datetime.datetime.utcnow() } posts.insert_one(post) posts.insert_one(post2) post = posts.find_o...

Can't download VBoxGuestAdditions directly? Here's the solution!

1. Choose the right version of your software https://download.virtualbox.org/virtualbox/ 2. Mount the VBoxGuestAdditions.iso Right-click Devices -> Optical Drivers -> Choose disk image -> find the VBoxGuestAdditions.iso 3. Install the VBoxGuestAdditions Go to 'My Computer', go to 'VBox Guest Additions', install what you can install 4. Done Reboot and enjoy it.

我为什么不喜欢中国互联网

中国互联网是倒退式发展的典型案例 他们并没有真正联网,企业做得越大,信息搞得越封闭 你无法在搜索引擎上搜索到任何有意义的东西 一方面是因为没人提供可被搜索引擎收录的页面,另一方面是政府的审查实在太严格,没人肯冒风险让资源自由流通 直接结果是,中国的互联网企业不断的把用户提供的数据框定在一个APP中。 他们不断地压缩你获取资源的方式,有时甚至倒退到“面对面快穿”。 而它们利用网页技术的方式则更为奇葩,仍是把它框定在一个APP里,美其名曰“小程序”。这种网页仍然不能被搜索引擎收录。 如果说不能被搜索引擎搜索到的网页被称为“暗网”,那我相信中国绝对是一个“暗网大国”。

Convert PDF to searchable PDF

For Chinese: ``` ocrmypdf -l chi_sim --deskew --title "yingshaoxo's pdf" --jobs 3 --output-type pdfa input.pdf output_searchable.pdf ``` For English: ``` ocrmypdf -l en --deskew --title "yingshaoxo's pdf" --jobs 3 --output-type pdfa input.pdf output_searchable.pdf ```

Let's rock the Raspberry Pi

#### 1. set wifi ``` sudo vi etc/wpa_supplicant/wpa_supplicant.conf ``` ``` ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={     ssid="wifi_name"     psk="password" } ``` #### 2. set ssh create a file in `boot` in SD card ``` cd /boot touch ssh ``` #### 3. allow root login ``` sudo vi etc/ssh/sshd_config ``` Change `PermitRootLogin prohibit-password` to `PermitRootLogin yes` #### 4. login ``` ssh pi@ip_address ``` default password is `raspberry` #### 5. change root password ``` sudo su passwd root ``` #### 6. reboot then using ssh ``` ssh root@ip_address ``` you can also using `ssh-copy-id root@ip_address` to use your key #### 7. mount external disk (only for EXT4 format) check info about disks: `sudo fdisk -l` check uuid about disks: `sudo blkid` ``` mkdir /media/usb vi /etc/fstab ``` ``` UUID=fee4308e-1c45-4229-a526-41f43b85928b /media/usb ext4 defaults,auto,...

Linux Screen Text Translator

1. Install `GoldenDict` ``` sudo apt-get install goldendict ``` 2. Install `translate-shell` https://github.com/soimort/translate-shell#option-1-direct-download 3. add `Google Source` as `Program` * open `GoldenDict`, chose `Edit`, then click `Dictionaries`, `Programs`, `Add` * add following ``` trans -e google -s en -t zh -show-original y -show-original-phonetics n -show-translation y -no-ansi -show-translation-phonetics n -show-prompt-message n -show-languages n -show-original-dictionary n -show-dictionary n -show-alternatives n "%GDWORD%" ``` 4. Enable `Scan Popup` Click `Edit`, `Preferences`,  `Scan Popup` > you may want to show popup only when you press `shift` key 5. Enjoy it! Force quit and restart ___ https://gist.github.com/yingshaoxo/3a3fa44bcbe59e764d828817b0f3d2fa

The computing world in my eyes

1. Linux  --> Ruled by C 2. Docker Container --> Ruled by Golang 3. Back-end Web Server --> Ruled by Python, PHP 4. Desktop view (including webpage) --> Ruled by Javascript 4. Mobile devices --> Ruled by Google(Java), Apple(Swift) ___ To be honest, I really don't know which way to go. But I think the oldest one, the kernel won't change.  I'd better study that. ___ And I also know, in any moment in the history, the final mission of programming is to automate everything, in another word, creating an AI to help us to do the job or replace humans.

Basic Windows 7 shortcuts

For website browsing, I recommend chrome and Vimium. Normally, these shortcuts you'll often use in Vimium: Show help: ? Scroll down: j Scroll up: k Scroll to the top of the page: gg Scroll to the bottom of the page: G Focus the first text input on the page: gi Do not focus on the input box: ESC Open URL, bookmark or history entry in a new tab: O Open a bookmark in a new tab: B Go one tab left: J Go one tab right: K Close current tab: x Restore closed tab: X Go back in history: H Go forward in history: L Copy the current URL to the clipboard: yy Open the clipboard's URL in a new tab: P Then comes windows controlling: Switch between open programs: ALT + TAB Quit program: ALT + F4 Closes the current Multiple Document Interface (MDI) window: CTRL + F4 Change the window size: Windows Logo + Up or Down arrow Change the window location: Windows Logo + Left or Right arrow Minimizes all open windows and displays the desktop: Windows Logo + D M...

终章 黄粱一梦

你好, 我叫英少。我正向新同学介绍我自己,so shame, 想起恍若昨日发生的一切,似乎有点迷乱。但看看四周,很好,我又回到现实了。 Wow, good. 我不是大神,也没混过黑道,更不清楚 AI 是什么东西。好吧,normal life.

第一章 外星来客

紧张的期末考来了,我对考试 already 麻木了,反正怎么考都是个倒数,在别人心急如焚答着题,或想尽办法作弊时,我却趴在那里 sleeping。 考试 time 眨眼间过去了,我的成绩 have a little 进步,排在了 the 57名,倒数第5了。 Then 就是 correct 试卷了,接着开散学典礼,我高一的学习生活 in this way over。收拾好东西,几件衣服和一条薄毯,慢悠悠的骑着辆2手自行车回到了我乡下的小屋。对我来说, 放假和不放假都差不多,一样的混日子,一样是我自个儿过。 夜深人静,我趴在窗台上,望着遥不可及的星, with 月亮半遮半掩的躲在云里。 前后左右的房子都熄了灯,望着 the outside 一片黑压压的村庄,突然 find 自己是那么的孤独,那么的与这个世界格格不入,我找不到活着的意义。这个世界没有人值得我眷恋,也不会有人眷恋我,这种感觉是那么的可怜。举目无亲,就是我这种吧, even one friend haven't !也对,谁会跟我这样的人做朋友? 再次抬头 look through the 有点悲凉的夜空,发现这个夜空好像有什么地方不同,东边多了一颗与众不同的星星,那颗星比其他的亮了好多。啊??还会动?我脑袋有点短路,这颗星星还真是奇怪啊,居然会移动。流星吗?我马上否决了这个想法,流星移动的速度可比这个快多了。 When 我乱猜时,那颗星星突然一闪,然后出现在了我头上的夜空中。还是那样亮,不过呆的地方却不一样了。 I can't help 目瞪口呆,这也太夸张了吧。UFO??我有点怀疑的擦了擦眼睛,再看,晕啊,没看花啊! 突然,有股吸力拉着我飞上天去,我心一紧,不要吧,外星人要抓我去研究了, suddenly, 我脑袋浮出了这样一张 picture,我被绑在手术床上,几个奇形怪状的外星人围着我。我一阵恶寒,脑袋也在这时候一阵眩晕。Before 昏迷,最后一个念头就是这下完了。 在我昏迷过去后,我的身体也凭空消失在窗台,那颗很亮的星也消失了, out of the sky,好像从来没出现过似的。 ——分割—— 不知过了多久,我迷迷糊糊的醒来,睁开眼睛, find out that 自己躺在一张奇怪的床上,四周都是一些奇怪的仪器,我突然 remembered 我...

Programming Language Tending

对于一个现代人 前端编程语言是这样学的: HTML→JavaScript→由JS引出的各种分支语言 后端编程语言是这样学的: Python→C++→汇编语言→计算机原理以及通用硬件制作与维修 前端后面为趋势,后端前面为趋势。 前者是从现实走进虚拟,后者是从虚拟走进现实。 感觉我是神棍😂