Skip to content

Instantly share code, notes, and snippets.

@haio
haio / gist:5581405
Created May 15, 2013 03:10
fib algorithm
function fib (n) {
if (n==0 || n==1) {
return 1;
} else {
return fib(n-2) + fib(n-1);
}
}
console.log(fib(3));
@haio
haio / gist:5567619
Last active December 17, 2015 06:48
We are all inventors, each sailing out on a voyage of discovery, guided each by a private chart, of which there is no duplicate. The world is all gates, all opportunities.
@haio
haio / gist:5545123
Created May 9, 2013 02:20
mysqldump
entire db:
mysqldump -u breezelark-p mydb > mydb.sql
one table:
mysqldump -u lingxi -p mydb mytb> mytb.sql
@haio
haio / gist:5524592
Created May 6, 2013 11:25
mysql root cant grant privileges
http://bugs.mysql.com/bug.php?id=45430
var interval = document.createElement('div');
interval.id = 'interval'
interval.style = 'margin-left: 600px;'
document.getElementsByClassName('code')[0].appendChild(interval);
var start = Date.now();
setTimeout(function () {
var interval_time = Math.floor((Date.now() - start)/1000);
var minutes = Math.ceil(interval_time/60 - 1);
var seconds = interval_time%60;
interval.innerHTML = "Oh, you have been cheating: " + minutes + 'minutes ' + seconds + ' seconds!!'
@haio
haio / gist:5459236
Created April 25, 2013 12:07
query table size in mysql
All Databases:
SELECT table_schema "Data Base Name", SUM( data_length + index_length) / 1024 / 1024
"Data Base Size in MB" FROM information_schema.TABLES GROUP BY table_schema ;
Specify Database:
SELECT TABLE_NAME, table_rows, data_length, index_length, round(((data_length + index_length) / 1024 / 1024),2) "Size in MB" FROM information_schema.TABLES WHERE table_schema = "db_holmes_admin_dw";
@haio
haio / gist:5457727
Last active December 16, 2015 15:39
mysql index
select * from t where c1 = ? and c2 = ? order by c3;
index -- t(c1, c2, c3)
http://hi.baidu.com/jadmin/item/8fed8527304d2bd5a517b60a
@haio
haio / gist:5453035
Created April 24, 2013 15:31
javascript char ascii
"char".charCodeAt(0);
String.fromCharCode(30058);
Magic the Gathering
时代气质