Skip to content

Instantly share code, notes, and snippets.

@nghuuphuoc
nghuuphuoc / gist:7226675
Last active December 26, 2015 22:59
Create MySQL database with UTF8 charset
CREATE DATABASE db_name CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANT ALL ON db_name.* TO user_name@localhost IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
@nghuuphuoc
nghuuphuoc / gist:7260275
Last active December 27, 2015 03:29
Create a large file
1) dd if=/dev/zero of=FileName bs=<block size> count=<block count>
The following command creates a file named big_file.dat with size of 1GB:
dd if=/dev/zero of=big_file.dat bs=1024 count=1000000
2) mkfile -n size[b|k|m|g] filename
For example:
mkfile -n 1g big_file.txt
@nghuuphuoc
nghuuphuoc / gist:7288062
Created November 3, 2013 09:34
Disable express.bodyParser() for file upload
// Instead of
// app.use(express.bodyParser())
// use:
app.use(express.json())
.use(express.urlencoded());
@nghuuphuoc
nghuuphuoc / gist:7348102
Last active December 27, 2015 15:29
Setup chroot SFTP on Centos
# See http://www.thegeekstuff.com/2012/03/chroot-sftp-setup/
$ groupadd apl_devs
$ useradd -g apl_devs -d /var/www/sass -s /sbin/nologin apl_dev_sass
$ passwd apl_dev_sass
Changing password for user apl_dev_sass.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
@nghuuphuoc
nghuuphuoc / 1) Install Nginx
Last active December 27, 2015 22:09
Install Nginx on Centos 6
$ rpm -Uvh http://nginx.org/packages/centos/6/x86_64/RPMS/nginx-1.4.7-1.el6.ngx.x86_64.rpm
$ chkconfig --add nginx
$ chkconfig --levels 235 nginx on
@nghuuphuoc
nghuuphuoc / gist:7398312
Last active March 17, 2021 02:58
Install npm, nodejs on Centos 6
# Enable Fedora Extra Packages for Enterprise Linux (EPEL) repos
$ rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# Install npm from the epel repos
$ sudo yum install npm --enablerepo=epel
@nghuuphuoc
nghuuphuoc / gist:7424235
Created November 12, 2013 02:08
Use wget with Basic Authentication
wget http://url --user=<user> --password=<password>
@nghuuphuoc
nghuuphuoc / gist:7428288
Created November 12, 2013 09:54
Split and join files on Mac/Linux
// Split file
$ split -b<size>m <bigFileName> <smallerFileName>
// Join files
$ cat <smallerFileName>* > <bigFileName>
For example:
$ split -b20m big.zip smaller.zip
$ cat smaller.zip* > big.zip
@nghuuphuoc
nghuuphuoc / gist:7766398
Created December 3, 2013 09:13
Clear DNS cache on Mac
// OS X Mountain Lion or Lion
$ sudo killall -HUP mDNSResponder
// Mac OS X v10.6
$ sudo dscacheutil -flushcache
@nghuuphuoc
nghuuphuoc / 1) Install
Last active December 30, 2015 02:59
Install MySQL 5 on Centos 6
// http://dev.mysql.com/doc/mysql-repo-excerpt/5.6/en/linux-installation-yum-repo.html
$ wget http://dev.mysql.com/get/mysql-community-release-el6-4.noarch.rpm
$ sudo yum localinstall mysql-community-release-el6-4.noarch.rpm
// Check MySQL Yum repos has been added
$ sudo yum repolist enabled | grep "mysql-community"
Failed to set locale, defaulting to C
mysql-community MySQL Community Server 19