To prevent the same mistake from happening again, it’s important to identify the root cause of the mistake and take corrective actions to address it. Here are some steps you can take to prevent the same mistake from happening again:
Continue reading “How to prevent the same mistake from happening again”How do I clone a subdirectory only of a Git repository?
In this example, I will checkout crm
from react-admin/examples/crm
folder in react-admin
repository. The steps to do a sparse clone are as follows
mkdir admin-crm
cd admin-crm
git init
git remote add -f origin https://github.com/marmelab/react-admin.git
This creates an empty repository with your remote, and fetches all objects but doesn’t check them out. Then do:
git config core.sparseCheckout true
Now you need to define which files/folders you want to actually check out. This is done by listing them in .git/info/sparse-checkout
, eg:
echo "examples/crm" >> .git/info/sparse-checkout
# echo "another/sub/tree" >> .git/info/sparse-checkout
Last but not least, update your empty repo with the state from the remote:
git pull origin master
You will now have files “checked out” for examples/crm
on your file system (with those paths still), and no other paths present.
Code of conduct
Mỗi lần đọc CoC của công ty lại gật gù, “ồ, đúng rồi, ai cũng biết ai cũng nghĩ thế nhưng phải có văn bản rõ ràng câu từ như thế” mới là kiểu Mỹ chứ.
Continue reading “Code of conduct”Sách
Từ hối có Bin bố ko còn nhiều thời gian đọc sách. Thực ra trước cũng lười, nhưng lúc đi học trở lại cũng đọc dc thêm mấy quyển. Và rồi dành nhiều thời gian bế Bin thì bố chuyển sang nghe audiobook. Cả năm vừa rồi bố cũng nghe dc kha khá các quyển về lịch sử, về con người, một số tác phẩm kinh điển của văn học VN và nước ngoài.
Hôm nay lại nghe lại nhà giả kim, đúng là Nhà giả kim có một cái gì đó rất đặc biệt. Lần này nghe lại tại suy nghĩ đôi điều. Thực sự thì mình muốn gì, giấc mơ của mình là gì, mình có cố gắng đi về phía mình mong muốn. Nếu thực sự mong muốn điều gì, cả vũ trụ này sẽ giúp ta thực hiện mong muốn của mình. Thực vậy ư…
Nếu đặt câu hỏi thực sự đúng, đúng câu hỏi thì mình sẽ nhận được câu trả lời, thực ra đó chính là câu trả lời từ trong thâm tâm của mình. Còn nếu ko có câu trả lời thì câu hỏi mình đưa ra chưa đủ rõ.
Nghe rất đơn giản, cũng như W. Buffett nói, nguyên tắc 1 là ko dc để mất tiền, nguyên tắc số 2 là luôn ghi nhớ nguyên tắc số 1. Những người chưa biết về ông thì nghĩ nó vớ vẩn, kiểu ông giàu ông nói gì chẳng đúng. Nhưng khi được biết về ông (qua cuốn sách về ông – quá trình hình thành nhà tư bản Mỹ) thì mình mới thấy rằng, ông nói đúng là ông làm đúng như vậy, nói một cách khác, W. Buffett ko khoanh tay đứng nhìn khoản đầu tư của mình thua lỗ, ông sẽ làm những việc cần làm để đảm bảo dc nguyên tắc số 1 của mình – đó cũng chính là nguyên tắc số 2 của ông.
Người bán kem gợi lên cho mình suy nghĩ về bản thân của vài năm về trước, muốn đi đây đi đó nhưng ko thực hiện mà nghĩ rằng đợi một lúc nào đó …
Người bán pha gợi lên bản thân của hiện tại, biết rằng cuộc sống phải kéo theo nhiều mối lo, sợ rằng giấc mơ thành hiện thực thì nó lại ko được như mình mong muốn.
Nếu mình ko code thì bug chắc chắn ko dc fix, và càng lâu thì mình sẽ càng stress trong đống bug của mình.
Giấc mơ tới miền đất lá phong đỏ xa xôi, tận hưởng bầu trời trong xanh, sống trong ngôi nhà ấm áp ánh đèn vàng bên ngoài tuyết bay bay, ánh mặt trời tà tà phía chân trời,..
Nó phải được bắt đầu. IELTS, học thạc sĩ, công việc 4k5.
Download YouTube playlist a set of MP3s
Requirements
python3 -m pip install pytube
sudo apt-get install rename
Script
Save the following lines as a file, eg pytubemp3.py
. Don’t forget to set your own playlists
from pytube import Playlist
links = ["https://www.youtube.com/watch?v=vvvvv&list=xxxxxxx",
"https://www.youtube.com/watch?v=vvvvv&list=xxxxxxx"]
for link in links:
playlist = Playlist("https://youtube.com/playlist?" + link.split("&")[1])
for video in playlist.videos:
print("Downloading: ", video.title,"from", video.watch_url)
video.streams.filter(only_audio=True).first().download()
Make sure your script is formatted with indents as the image below:

Then run:
python pytubemp3.py
. This step save the audio of youtube video asmp4
file.rename "s/mp4$/mp3/" *.mp4
. This step replace the suffixmp4
withmp3
Linux: Access directly to the shell in case of boot failure
Why
Sometimes, we mess up with Ubuntu (for example), then we are not able to boot to the graphical user interfaces. We may fix the issue with the command line, but we cannot access the command line because of failures during boot time.
In this case, we can edit the grub boot option, to access the shell. Then we made changes, then reboot.
With this trick, we can even reset the root password without remembering the current password.
How
When the grub shows the menu of operating systems to boot, press e
to edit the menu of current entry.
Find the line that contains linux... vmlinux ... ro
. We need to:
ro
=>rw
Any change has to be writen to the system.- add
init=/bin/sh
- Press
Ctrl
+X
to boot
That’s it. If you know this trick, you are probably know how to fix your own issue.
I guess anyone who jumps into this post via search engine just doesn’t remember the exact parameter, but they know how already. Please comment if this post help you 🙂
InRelease’ changed its ‘Suite’ value from ‘testing’ to ‘stable’: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details.
If someone gets it as well then the solution is relatively simple. Run apt-get --allow-releaseinfo-change update
x@pi-server-02 /etc/apt sudo apt-get update
Hit:1 https://download.docker.com/linux/raspbian bullseye InRelease
Hit:2 https://deb.nodesource.com/node_10.x bullseye InRelease
Get:3 http://raspbian.raspberrypi.org/raspbian bullseye InRelease [15.0 kB]
Reading package lists… Done
E: Repository 'http://raspbian.raspberrypi.org/raspbian bullseye InRelease' changed its 'Suite' value from 'testing' to 'stable'
N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details.
After
x@pi-server-02 /etc/apt sudo apt-get --allow-releaseinfo-change update
Hit:1 https://download.docker.com/linux/raspbian bullseye InRelease
Hit:2 https://deb.nodesource.com/node_10.x bullseye InRelease
Get:3 http://raspbian.raspberrypi.org/raspbian bullseye InRelease [15.0 kB]
Get:4 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages [13.2 MB]
Get:5 http://raspbian.raspberrypi.org/raspbian bullseye/contrib armhf Packages [60.2 kB]
Get:6 http://raspbian.raspberrypi.org/raspbian bullseye/non-free armhf Packages [106 kB]
Get:7 http://raspbian.raspberrypi.org/raspbian bullseye/rpi armhf Packages [1360 B]
Fetched 13.4 MB in 22s (621 kB/s)
Reading package lists... Done
N: Repository 'http://raspbian.raspberrypi.org/raspbian bullseye InRelease' changed its 'Suite' value from 'testing' to 'stable'
x@pi-server-02 /etc/apt sudo apt-get update
Hit:1 https://deb.nodesource.com/node_10.x bullseye InRelease
Hit:2 https://download.docker.com/linux/raspbian bullseye InRelease
Hit:3 http://raspbian.raspberrypi.org/raspbian bullseye InRelease
Reading package lists... Done
Bash: set up a temporary SSH tunnel
You can do this cleanly with an ssh ‘control socket’. To talk to an already-running SSH process and get its PID, kill it etc. Use the ‘control socket’ (-M
for master and -S
for socket) as follows:
ssh -M -S my-ctrl-socket -fnNT -L 50000:localhost:3306 [email protected]
ssh -S my-ctrl-socket -O check [email protected]
Master running (pid=3517)
ssh -S my-ctrl-socket -O exit [email protected]
Exit request sent.
Note that my-ctrl-socket will be an actual file that is created.
You can use -o ExitOnForwardFailure=yes
with -f
and SSH will wait for all remote port forwards to be successfully established before placing itself in the background. You can grep the output of ps to get the PID. For example, you can use
ssh -Cfo ExitOnForwardFailure=yes -N -L 9999:localhost:5900 $REMOTE_HOST
PID=$(pgrep -f 'N -L 9999:')
[ "$PID" ] || exit 1
and be pretty sure you’re getting the desired PID
WordPress with nginx
See https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/php-nginx/162475923957101.sock/socket;
#The following parameter can be also included in fastcgi_params file
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
Ubuntu/Linux: Ibus cannot work with some UI app
Add to /etc/profile
, or ~/.bashrc
then open your app from the new tab of terminal
export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus