Skip to content

Instantly share code, notes, and snippets.

View hien's full-sized avatar
🏠
Working from home

Hien Phan hien

🏠
Working from home
View GitHub Profile
#!/bin/sh
path="/var/log/server-status"
ddd=`date +%Y-%m-%d`
logfile=$path/$ddd/logfile.txt
lockfile=$path/getstatus.running
### Check if one instance is running, if not create a lockfile and run the script
if [[ -f $lockfile ]] ; then
exit
fi
@hien
hien / wtf.sh
Created November 29, 2017 06:15 — forked from rothgar/wtf.sh
Linux server debugging in 60 seconds
#!/bin/bash
# Taken from https://medium.com/netflix-techblog/linux-performance-analysis-in-60-000-milliseconds-accc10403c55
# initialize array
COMMANDS=('uptime')
# add systemctl command if it's installed
command -v systemctl >/dev/null && COMMANDS+=('systemctl list-units --state=failed')
# add more commands
COMMANDS+=('dmesg | tail'
'vmstat 1'
wget http://speedtest.fpt.vn/speedtest/random4000x4000.jpg -O /dev/null
wget http://speedtestkv3a.viettel.vn/speedtest/random4000x4000.jpg -O /dev/null
wget http://speedtest3.vtn.com.vn/speedtest/random4000x4000.jpg -O /dev/null

Create Boot CD for Openstack

Why?

I got stuck when trying to extend the root partition. The partition table ended up broken and I cannot boot into the system.

Preparation

  • download Hiren Boot CD, it will come in .iso format
  • install syslinux in the system (sudo yum install -y syslinux)

Make the CD image with partition table

@hien
hien / python_decorator_guide.md
Created August 30, 2018 07:10 — forked from Zearin/python_decorator_guide.md
The best explanation of Python decorators I’ve ever seen. (An archived answer from StackOverflow.)

NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.


Q: How can I make a chain of function decorators in Python?


If you are not into long explanations, see [Paolo Bergantino’s answer][2].

Keybase proof

I hereby claim:

  • I am hien on github.
  • I am hien (https://keybase.io/hien) on keybase.
  • I have a public key ASBJ-yvlnLEdTx2OaS48VyT9P_Al_0_wOtDwMrx4MajvkQo

To claim this, I am signing this object:

@hien
hien / readme.md
Created January 9, 2019 13:18 — forked from eddiewebb/readme.md
Hugo JS Searching with Fuse.js
@hien
hien / go-os-arch.md
Created January 12, 2019 16:21 — forked from asukakenji/0-go-os-arch.md
Go (Golang) GOOS and GOARCH

Go (Golang) GOOS and GOARCH

All of the following information is based on go version go1.8.3 darwin/amd64.

A list of valid GOOS values

(Bold = supported by go out of the box, ie. without the help of a C compiler, etc.)

  • android
  • darwin

FWIW: I didn't produce the content presented here (the outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@hien
hien / master.vim
Created April 13, 2019 14:22 — forked from benjamincharity/master.vim
Master Vim with this interactive tutorial.
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)