Skip to content

Instantly share code, notes, and snippets.

@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: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: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 / newFile1.txt
Created April 17, 2014 02:37
Change Wordpress domain name
update wp_options set option_value='http://ri-zone.zoodemo.com' where option_name='siteurl';
@nghuuphuoc
nghuuphuoc / gist:5a9322bd2fcf84c7cd46
Created September 10, 2014 05:58
Reset file permissions
for package in $(rpm -qa); do rpm --setperms $package; done
for package in $(rpm -qa); do rpm --setugids $package; done
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@nghuuphuoc
nghuuphuoc / trello-css-guide.md
Last active August 29, 2015 14:26 — forked from bobbygrace/trello-css-guide.md
Trello CSS Guide

Trello CSS Guide

“I perfectly understand our CSS. I never have any issues with cascading rules. I never have to use !important or inline styles. Even though somebody else wrote this bit of CSS, I know exactly how it works and how to extend it. Fixes are easy! I have a hard time breaking our CSS. I know exactly where to put new CSS. We use all of our CSS and it’s pretty small overall. When I delete a template, I know the exact corresponding CSS file and I can delete it all at once. Nothing gets left behind.”

You often hear updog saying stuff like this. Who’s updog? Not much, who is up with you?

This is where any fun you might have been having ends. Now it’s time to get serious and talk about rules.

Writing CSS is hard. Even if you know all the intricacies of position and float and overflow and z-index, it’s easy to end up with spaghetti code where you need inline styles, !important rules, unused cruft, and general confusion. This guide provides some architecture for writing CSS so it stays clean and ma

@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