This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function.prototype.method = function(name, func) { | |
if(!this.prototype[name]) { | |
this.prototype[name] = func; | |
} | |
return this; | |
}; | |
Number.method('integer', function() { | |
return Math[this < 0 ? 'ceil' : 'floor'](this); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var memoizer = function (memo, formula) { | |
var recur = function(n) { | |
var result = memo[n]; | |
if(typeof result !== 'number') { | |
result = formula(recur, n); | |
memo[n] = result; | |
} | |
return result; | |
}; | |
return recur; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var is_array = function(value) { | |
return Object.prototype.toString.apply(value) === '[object Array]'; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# chkconfig: 2345 55 25 | |
# Description: Nginx init.d script, put in /etc/init.d, chmod +x /etc/init.d/nginx | |
# For Debian, run: update-rc.d -f nginx defaults | |
# For CentOS, run: chkconfig --add nginx | |
# | |
### BEGIN INIT INFO | |
# Provides: nginx | |
# Required-Start: $all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def split(x): | |
def sp(n,m): | |
if m>n: | |
raise StopIteration | |
else: | |
for i in range(m,n//2+1): | |
for l in sp(n-i,i): | |
yield [i]+l | |
yield [n] | |
for i in sp(x,1): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import os | |
#书籍信息 | |
title='test book' | |
creator='scturtle' | |
description='blablablabla' | |
#章节文件 | |
txtlist=['1.txt','2.txt'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Post extends Component { | |
constructor () { | |
super() | |
this.state = { content: '' } | |
} | |
componentWillMount () { | |
this._loadData() | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Register { | |
constructor() { | |
this.routes = [] | |
} | |
regist(obj, k, fn) { | |
const _i = this.routes.find(function(el) { | |
if((el.key === k || el.key.toString() === k.toString()) | |
&& Object.is(el.obj, obj)) { | |
return el |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Singleton { | |
private $_instance; | |
private function __construct() {} | |
private function __clone() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// we can use this, make our code simple and short. | |
class MethodTest | |
{ | |
public function __call($name, $arguments) | |
{ | |
// Note: value of $name is case sensitive. | |
echo "Calling object method '$name' " |
OlderNewer