Skip to content

Instantly share code, notes, and snippets.

@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: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 / newFile1.txt
Created Apr 17, 2014
Change Wordpress domain name
View newFile1.txt
update wp_options set option_value='http://ri-zone.zoodemo.com' where option_name='siteurl';
View gist:5a9322bd2fcf84c7cd46
for package in $(rpm -qa); do rpm --setperms $package; done
for package in $(rpm -qa); do rpm --setugids $package; done
View markdown.css
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
View node-and-npm-in-30-seconds.sh
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
View trello-css-guide.md

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 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