Skip to content

Instantly share code, notes, and snippets.

@nghuuphuoc
nghuuphuoc / gist:10518179
Created Apr 12, 2014
Change Magento domain name
View gist:10518179
update core_config_data set value = 'http://domainname/' where path = 'web/unsecure/base_url';
update core_config_data set value = 'http://domainname/' where path = 'web/secure/base_url';
@nghuuphuoc
nghuuphuoc / gist:10514380
Last active Aug 29, 2015
Install Nexcessnet_Turpentine for Magento
View gist:10514380
1) Install Varnish first
https://gist.github.com/nghuuphuoc/7819928
2) Install Nexcessnet_Turpentine
$ cd <Magento directory>
$ chmod 755 mage
$ ./mage install connect20.magentocommerce.com/community Nexcessnet_Turpentine
Checking dependencies of packages
Starting to download Nexcessnet_Turpentine-0.6.0.tgz ...
...done: 59,467 bytes
@nghuuphuoc
nghuuphuoc / gist:9948331
Created Apr 3, 2014
Highlight a keyword without breaking tag
View gist:9948331
// $value is the original string
// $keyword is the searching keyword
function highlight($value, $keyword) {
try {
$dom = new DomDocument();
@$dom->loadHtml($value);
$xpath = new DomXpath($dom);
$upper = strtoupper(addslashes($keyword));
$lower = strtolower(addslashes($keyword));
// Support i-case sensitive using translate method provided by XPath 1.0
@nghuuphuoc
nghuuphuoc / gist:8331575
Created Jan 9, 2014
chmod files to 644 and all folders to 755
View gist:8331575
$ find . -type d -print0 | xargs -0 chmod 0775
$ find . -type f -print0 | xargs -0 chmod 0664
@nghuuphuoc
nghuuphuoc / gist:8311022
Created Jan 8, 2014
Remove .svn files recursively
View gist:8311022
$ find . -name .svn -exec rm -rf {} \;
@nghuuphuoc
nghuuphuoc / gist:8282411
Last active Feb 19, 2021
Install wkhtmltopdf on Centos 6 x64
View gist:8282411
$ wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-amd64.tar.bz2
$ tar xvjf wkhtmltopdf-0.9.9-static-amd64.tar.bz2
$ mv wkhtmltopdf-amd64 /usr/bin/wkhtmltopdf
// In case you got the issue
// wkhtmltopdf: error while loading shared libraries:
// libfontconfig.so.1: cannot open shared object file: No such file or directory
//
// run the command below:
$ yum install urw-fonts libXext libXrender fontconfig libfontconfig.so.1
@nghuuphuoc
nghuuphuoc / gist:8144617
Created Dec 27, 2013
NodeJS behide Nginx
View gist:8144617
server {
listen 80;
server_name domain.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
@nghuuphuoc
nghuuphuoc / Add swap
Last active Dec 7, 2020
Fix MySQL issue "Fatal error: cannot allocate memory for the buffer pool" on Digital Ocean server
View Add swap
// Check swap
$ sudo swapon -s
Filename Type Size Used Priority --> empty
// Create and enable swap file
$ sudo dd if=/dev/zero of=/swapfile bs=1024 count=512k
$ sudo mkswap /swapfile
Setting up swapspace version 1, size = 262140 KiB
no label, UUID=103c4545-5fc5-47f3-a8b3-dfbdb64fd7eb
@nghuuphuoc
nghuuphuoc / gist:7904221
Last active Dec 30, 2015
Allow Wordpress to update the plugin without asking for FTP account
View gist:7904221
// Add the following line to wp-config.php
define('FS_METHOD','direct');
// Set wp-content permission
$ chmod -R 775 wp-content/
$ chown -R nginx:nginx wp-content/
@nghuuphuoc
nghuuphuoc / gist:7886804
Last active Dec 30, 2015
Nginx config for Wordpress Super Cache plugin
View gist:7886804
server {
set $supercache_file '';
set $supercache_uri $request_uri;
if ($request_method = POST) {
set $supercache_uri '';
}
# Using pretty permalinks, so bypass the cache for any query string
if ($query_string) {