Skip to content

Instantly share code, notes, and snippets.

View island205's full-sized avatar
🎯
Focusing

Zhi Cun island205

🎯
Focusing
View GitHub Profile
@island205
island205 / critique.md
Created December 5, 2011 02:05 — forked from Raynos/critique.md
jQuery library critique

jQuery

$ itself is a god object. Everything goes on it. The standard plugin / extension architecture that is recommended is to just bolt more methods on $ itself!

Surely this is bad. An example would be how we have both $.load which is overloaded to do completely different things. If they were on two separate sensibly named objects $Container.load and $EventTarget.load. Personally I would deprecate the latter in favour of .on('load'

The animation should be it's own little modular thing, not bolted onto $. Ajax should be it's own little modular thing, not bolted onto $

$

@island205
island205 / dabblet.css
Created December 16, 2011 08:00
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height:100%;
class HanJiaJun
###
相当于JS中的构造函数
###
constructor:(@name)->
console.log "I am HanJiaJun!"
###
原型方法
###
write:(title)->
(function() {
var HanHan, HanJiaJun;
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
};
class Vector2
x: 0
y: 0
constructor:() ->
constructor:(@x, @y) ->
constructor:(vector) ->
x = vector.x
new Vector
new Vector 1,1
new Vector {x:1,y:1}
class Vector
###
构造函数这里使用了默认参数和属性参数
###
constructor:(@x=0,@y=0) ->
if typeof @x is "object"
###
这里的vector为了解决给@x赋值的问题,当然使用
@y=@x.y
@x=@x.x
var Vector;
Vector = (function() {
/*
构造函数这里使用了默认参数和属性参数
*/ function Vector(x, y) {
var vector;
this.x = x != null ? x : 0;
this.y = y != null ? y : 0;
if (typeof this.x === "object") {
/*
###
AOP开始
###
DO =
objs: {}
before: (fn, obj, sFn, c) ->
after: (fn, obj, sFn, c) ->
_inject: (when_, fn, obj, sFn) ->
@island205
island205 / gist:2835281
Created May 30, 2012 09:59
模板语言语法分析
{{Variable}}
{{#if conditions}}
BLOCK
{{/if}}
{{#if conditions}}
BLOCK
{{#elseif conditions}}
ELSEIF BLOCK