Skip to content

Instantly share code, notes, and snippets.

View linhxhust's full-sized avatar

Linh Nguyen linhxhust

View GitHub Profile
@linhxhust
linhxhust / Wget website copier
Last active June 2, 2016 09:53
Using wget to download website
wget -erobots=off --no-parent --wait=3 --limit-rate=20K -r -p -U "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)" -A htm,html,css,js,json,png,gif,jpeg,jpg,bmp,ttf,svg,woff,woff2,eot http://domain.com/index.html
@linhxhust
linhxhust / Add git branch to PS1
Last active December 4, 2022 09:56
Add git branch to PS1
Step 1: Open file ~/.bashrc
Step 2: Uncomment forece_color_prompt=yes
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes
Step 3: Comment PS1 style. Add the following code to end of ~/.bashrc
@linhxhust
linhxhust / hhvm_php.ini
Created June 30, 2016 11:28 — forked from colin-kiegel/hhvm_php.ini
ILIAS / HHVM / Nginx configs
; /etc/hhvm/php.ini
; php options
session.save_handler = files
session.save_path = /var/lib/php5
session.gc_maxlifetime = 1440
; hhvm specific
hhvm.log.level = Warning
hhvm.log.always_log_unhandled_exceptions = true ; (!)
ps -elf | awk '/<process_name>/ && !/awk/ {print $4}' | xargs -r kill -s SIGTERM
(function() {var pname = ( (document.title !='')? document.title : document.querySelector('h1').innerHTML );var ga = document.createElement('script'); ga.type = 'text/javascript';ga.src = '//live.vnpgroup.net/js/web_client_box.php?hash=93f97340dee3be6f82e8d12586d0675a&data=eyJzc29faWQiOjIxMzExNjksImhhc2giOiIwODBiNTI0NGQyZTVkMjU1ODgzYjE0NzMzMDVkNzRiOCJ9&pname='+pname;var s = document.getElementsByTagName('script');s[0].parentNode.insertBefore(ga, s[0]);})();
#!/bin/bash
SAMPLE_ARR=("one" "two" "three" "four")
printf ${SAMPLE_ARR[*]} # one two three four
printf ${SAMPLE_ARR[@]} # one two three four
printf ${SAMPLE_ARR[1]} # two
#!/bin/bash
SAMPLE_ARR=("one" "two" "three" "four")
#!/bin/bash
SAMPLE_DICT=([index1]=value1 [index2]=value)
# or
SAMPLE_DICT[index1]="value1"
SAMPLE_DICT[index2]="value2"
#!/bin/bash
cdr_array=(
"rec:/path/to/cdr/rec"
"sms:/path/to/cdr/sms"
"mgr:/path/to/cdr/mgr"
"vou:/path/to/cdr/vou"
)
for cdr in "${cdr_array[@]}" ; do
#!/bin/bash
ping -c 3 127.0.0.1
if [ $? -ne 0 ]; then
printf "Couldn't ping to 127.0.0.1"
fi