Skip to content

Instantly share code, notes, and snippets.

View luozhihua's full-sized avatar

Colin Luo luozhihua

View GitHub Profile
@luozhihua
luozhihua / Function-inherit.js
Created August 1, 2013 13:41
JavaScript inherit solution
;(function(){
function do_inherit(cls_1, parent_1, opt) {
var inherited = is_inherited.call(this, cls_1, parent_1),
parent = typeof parent_1 === 'function' ? new parent_1(opt) : parent_1;
if (!cls_1.supperclass || !inherited) {
cls_1.supperclass = parent_1;
cls_1.prototype = tbc.extend(parent, cls_1.prototype, {
/**
@luozhihua
luozhihua / auto-restart-nodejs-process
Last active August 7, 2022 06:21
Auto restart nodejs process when program exit
var child_process = require('child_process');
start();
function start(nodefile) {
if (typeof start !== 'string') {
console.log('Has none file. like this: start("app.js")');
}
console.log('Master process is running.');
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
</body>
</html>
@luozhihua
luozhihua / Get Forms Value
Created January 3, 2014 02:29
Get all forms value with form element.
var formData = {};
$('#form-ID').find('input,select,textarea').each(function() {
var name = this.name || this.id,
type = (this.getAttribute('type')||'').toLowerCase(),
value;
switch (type) {
case 'radio':
value = this.checked ? this.value : value;
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<div data-async-context="query:js在线编辑" id="ires"><ol eid="SszGUt_FMuL9iAetq4DIDA" id="rso"><li class="g"><!--m--><div class="rc" data-hveid="42"><span class="altcts"></span><h3 class="r"><a href="/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;ved=0CCsQFjAA&amp;url=%68%74%74%70%3a%2f%2f%72%75%6e%6a%73%2e%63%6e%2f&amp;ei=SszGUt_FMuL9iAetq4DIDA&amp;usg=AFQjCNGu-1-E_gWJDzGuf2nyWnd9lwni1A&amp;sig2=IWcE5aDmZdVpzRTNQX-RIw" onmousedown="return rwt(this,'','','','1','AFQjCNGu-1-E_gWJDzGuf2nyWnd9lwni1A','IWcE5aDmZdVpzRTNQX-RIw','0CCsQFjAA','','',event)" target="_blank" data-href="http://runjs.cn/">RunJS - <em>在线编辑</em>、展示、分享、交流你的<em>JavaScript</em> 代码</a></h3><div class="s"><div><div class="f kv" style="white-space:nowrap"><cite class="vurls">runjs.cn/</cite>‎<div class="action-menu ab_ctl"><a class="clickable-dropdown-arrow
@luozhihua
luozhihua / javascript_resources.md
Created January 21, 2014 04:17 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@luozhihua
luozhihua / css_resources.md
Created January 21, 2014 04:17 — 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

@luozhihua
luozhihua / python_resources.md
Created January 21, 2014 04:17 — 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

<!DOCTYPE html>
<html>
<head>
<script src="http://requirejs.org/docs/release/2.1.10/comments/require.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
@luozhihua
luozhihua / module.js
Last active August 29, 2015 13:57
How to define an universal module?
(function(global) {
function Person() {
this.name = 'luozhihua';
this.company = 'tbc.com';
}
Person.prototype = {
say : function(words) {
alert(words || "I can't say any more, you know that.");