Skip to content

Instantly share code, notes, and snippets.

@nghuuphuoc
nghuuphuoc / gist:10518179
Created April 12, 2014 04:01
Change Magento domain name
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 August 29, 2015 13:59
Install Nexcessnet_Turpentine for Magento
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 April 3, 2014 04:36
Highlight a keyword without breaking tag
// $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 January 9, 2014 09:22
chmod files to 644 and all folders to 755
$ find . -type d -print0 | xargs -0 chmod 0775
$ find . -type f -print0 | xargs -0 chmod 0664
@nghuuphuoc
nghuuphuoc / gist:8311022
Created January 8, 2014 02:55
Remove .svn files recursively
$ find . -name .svn -exec rm -rf {} \;
@nghuuphuoc
nghuuphuoc / gist:8282411
Last active February 11, 2022 18:45
Install wkhtmltopdf on Centos 6 x64
$ 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 December 27, 2013 09:35
NodeJS behide Nginx
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 December 7, 2020 10:55
Fix MySQL issue "Fatal error: cannot allocate memory for the buffer pool" on Digital Ocean server
// 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 December 30, 2015 23:59
Allow Wordpress to update the plugin without asking for FTP account
// 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 December 30, 2015 21:19
Nginx config for Wordpress Super Cache plugin
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) {