Thursday, January 31, 2013

Average File Size in Directory

find print/ -type f -print0 | xargs -0 ls -l | gawk \ '{sum += $5; n++;} END {print "Total Size: " sum/1024/1024 " MB : Avg Size: " sum/n/1024 " KB : Total Files: " n ;}'

Tuesday, January 29, 2013

Clearing cache for druplal node

cache_get('content:12345:23456', 'cache_content'); # get the data cache_clear_all('content:nid:vid', 'cache_content') # clear that specific nid/vid combination cache_clear_all('content:nid', 'cache_content', TRUE) # clear all cached revisions of that nid

Then vs. Than

Then - is another word for “after.” Incidentally, the word “then” makes for boring writing.
Than - is a comparative word (e.g. I am smarter than you).

Wednesday, January 2, 2013

How ti import CSV file into MySQL table


LOAD DATA INFILE "file.csv"
INTO TABLE __source_data
COLUMNS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '"'
LINES TERMINATED BY '\n';

OR

LOAD DATA INFILE "/home/mike/data.csv"
INTO TABLE my_TABLE
COLUMNS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 LINES;