Skip to content

Instantly share code, notes, and snippets.

@nghuuphuoc
nghuuphuoc / gist:7226675
Last active Dec 26, 2015
Create MySQL database with UTF8 charset
View gist:7226675
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 Dec 27, 2015
Create a large file
View gist:7260275
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 Nov 3, 2013
Disable express.bodyParser() for file upload
View gist:7288062
// Instead of
// app.use(express.bodyParser())
// use:
app.use(express.json())
.use(express.urlencoded());
@nghuuphuoc
nghuuphuoc / gist:7348102
Last active Dec 27, 2015
Setup chroot SFTP on Centos
View gist:7348102
# 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 Dec 27, 2015
Install Nginx on Centos 6
View 1) Install Nginx
$ 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 Mar 17, 2021
Install npm, nodejs on Centos 6
View gist:7398312
# 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 Nov 12, 2013
Use wget with Basic Authentication
View gist:7424235
wget http://url --user=<user> --password=<password>
@nghuuphuoc
nghuuphuoc / gist:7428288
Created Nov 12, 2013
Split and join files on Mac/Linux
View gist:7428288
// 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 Dec 3, 2013
Clear DNS cache on Mac
View gist:7766398
// OS X Mountain Lion or Lion
$ sudo killall -HUP mDNSResponder
// Mac OS X v10.6
$ sudo dscacheutil -flushcache
@nghuuphuoc
nghuuphuoc / 1) Install
Last active Dec 30, 2015
Install MySQL 5 on Centos 6
View 1) Install
// 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