Tuesday, November 09, 2010

Handle JSON.parse in IE 6

IE 6 seems can not recognize JSON.parse(), there's many way to fix this, one is to use the json2 library, http://json.org/json2.js, just include the file in your document, then you will be able to use JSON.parse() or JSON.stringify().
More details take a look at this post: http://stackoverflow.com/questions/1787020/json-object-in-ie6-how

Friday, July 30, 2010

CSS3 PIE on IE8 non-senseness

If you having issue on rendering CSS3 property on IE8 using CSS3 PIE, chance are you have to set the element position to relative, otherwise the element may be disappeared.

nav a {
position: relative;
padding: 6px 25px;
color: #ffffff;
font-size: 13px;
font-weight: bold;
background-color: #e37222;
text-decoration: none;
display: block;
float: left;
margin-right: 3px;
-moz-box-shadow: 0px 2px 3px #999999; /* FF3.5+ */
-webkit-box-shadow: 0px 2px 3px #999999; /* Saf3.0+, Chrome */
box-shadow: 0px 2px 3px #999999; /* Opera 10.5, IE 9.0 */
behavior: url(/assets/css/pie/PIE.htc);
}

Tuesday, May 11, 2010

Element weight in css

Never knowing this before, when css is rendering for a page, it actually calculating point to determine override rule.

HTML = 1 point
CLASS = 10 points
ID = 100 points

http://net.tutsplus.com/tutorials/html-css-techniques/quick-tip-understanding-css-specificity/

Make html5 element available in IE

First make all new element as block element in css, Second, in javascript, using Document.createElement("name of the new element") to create all new elements.
This way can trick IE to understand these element.
You may also embed a html5.js host by google that can do that for you.
http://html5shiv.googlecode.com/svn/trunk/html5.js

Thursday, January 07, 2010

Magic line to create file in nest structure

mkdir -p `dirname parentFolder/childFolder/file.txt` && touch parentFolder/childFolder/file.txt

Finding video info from command line

sudo apt-get install libimage-exiftool-perl
exiftool *.mp4 *.mpg *avi *mov

http://ubuntuforums.org/showthread.php?t=474839

Friday, December 11, 2009

Crob Job Example

1. crobtab -e
2. Add following line
* * * * * you command | logger "wget ran"
3. Save and exit. (You should see a message say "crontab: installing new crontab")

What does this command do?
It will run your command every min, and write a message to the system log. The system log usually locate at /var/log/messsages

More reference:
http://aplawrence.com/BDD/bbcronbasics.html
http://www.adminschoice.com/docs/crontab.htm

Thursday, December 10, 2009

Wordpress: Query Analysis

http://codex.wordpress.org/Editing_wp-config.php#Save_queries_for_analysis

Wednesday, November 25, 2009

ORDER by title in mysql, ignoring the word “The”

Often time when you want to sort your sql return record by title, but the title starts with the word "The", for example "The Mummy" and we wants to sort by "Mummy" instead.
There are 2 solutions I have found:
1. Create a new field on the fly and sort by using the new field.
Select *, str_replace(title, 'The ', '') as sort_title ORDER BY sort_title

2. For better query performance, create a new column in the table ('sort_title') that is same as the title column but without a prefix of "The " or "A".

Some more info can be found here: http://stackoverflow.com/questions/695664/how-do-you-order-by-title-in-mysql-ignoring-the-word-the