Skip to content

Instantly share code, notes, and snippets.

View leohxj's full-sized avatar
💯
Focusing

Leo Hui leohxj

💯
Focusing
View GitHub Profile
@leohxj
leohxj / python_resources.md
Created October 22, 2013 01:53 — forked from jookyboi/python_resources.md
Python-related modules and guides.

Packages

  • lxml - Pythonic binding for the C libraries libxml2 and libxslt.
  • boto - Python interface to Amazon Web Services
  • Django - Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
  • Fabric - Library and command-line tool for streamlining the use of SSH for application deployment or systems administration task.
  • PyMongo - Tools for working with MongoDB, and is the recommended way to work with MongoDB from Python.
  • Celery - Task queue to distribute work across threads or machines.
  • pytz - pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.4 or higher.

Guides

@leohxj
leohxj / css_resources.md
Created October 22, 2013 01:53 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

@leohxj
leohxj / oncefunc.js
Created October 22, 2013 01:53
只执行一次的函数的写法
var obj = new Object();
obj.triggerOnce = function(fn) { //控制让函数只触发一次
return function() {
try {
fn.apply(this, arguments);
}
catch (e) {
var txt = "There was an error on this page.\n\n";
txt += "Error message: " + e.message + "\n\n";
@leohxj
leohxj / floatInt.js
Created October 24, 2013 07:19
位运算取整数
~~(1.111) // 1
~~(1.555) // 1
@leohxj
leohxj / useSetTimeout.js
Created October 28, 2013 02:08
什么时候使用serTimeout()?
/*
* 假设write_log()花费1秒,那么read_data()得多等1秒才能返回,
* 然后show_data()才能把数据展示给用户。但是用户根本不关心你的日志,
* 让用户为此多等1秒其实毫无意义,这种场景就可以用setTimeout(callback,0)来调用write_log
* 让read_data()立刻返回并将数据展示给用户。node里可以用nextTick,会更快一些。
*/
function read_data(){
read_file();
write_log();
//setTimeout(write_log,0);
@leohxj
leohxj / gitignore
Created October 30, 2013 09:27
忽略文件
# 忽略*.o和*.a文件
*.[oa]
# 忽略*.b和*.B文件,my.b除外
*.[bB]
!my.b
@leohxj
leohxj / interviewQuestion.js
Created November 6, 2013 10:50
前端面试小题目
var len=4; while(len--){ setTimeout(function(){ alert(len); },0); alert(len); }
// output: 3,2,1,0,-1,-1,-1,-1.
var len=4; while(len--){ (function(i){ setTimeout(function(){ alert(i); },0); })(len); alert(len); }
// output: 3,2,1,0,1,2,3,0
@leohxj
leohxj / fixConsole.js
Created December 3, 2013 08:14
IE8 console
//fix IE first open
(function (con) {
'use strict';
var prop, method;
var empty = {};
var dummy = function () { };
var properties = 'memory'.split(',');
var methods = ('assert,count,debug,dir,dirxml,error,exception,group,' +
'groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,' +
'time,timeEnd,trace,warn').split(',');
@leohxj
leohxj / redirect.html
Created December 3, 2013 10:53
html跳转页面
<meta http-equiv="REFRESH" content="0;url=http://www.greensock.com/get-started-js/">
@leohxj
leohxj / rmdir.js
Last active December 30, 2015 11:09
nodejs 删除文件夹,默认node_modules
var fs = require('fs'),
rmdirPath = process.argv[2]? process.argv[2]: 'node_modules';
var rmdirSync = (function(){
function iterator(url,dirs){
var stat = fs.statSync(url);
if(stat.isDirectory()){
dirs.unshift(url);
inner(url,dirs);
}else if(stat.isFile()){