This file contains hidden or 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 Ring = (function() { | |
function Ring(list) { | |
this._list = [].slice.call(list, 0); | |
this._length = this._list.length; | |
this._curr = -1; | |
}; | |
Ring.prototype = { | |
rollTo: function(idx) { | |
this._curr = idx % this._length; | |
if (this._curr < 0) this._curr += this._length; |
This file contains hidden or 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
#Newbie programmer | |
def factorial(x): | |
if x == 0: | |
return 1 | |
else: | |
return x * factorial(x - 1) | |
print factorial(6) | |
#First year programmer, studied Pascal |
This file contains hidden or 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
/** | |
* 估算有多少人投票 | |
*/ | |
Math.round([].slice.call( | |
document.querySelectorAll( | |
'tbody td[bgcolor="#ffffff"]:nth-child(2)' | |
), 1) | |
.map(function(n){ | |
return parseInt( | |
n.innerHTML.split(':(')[1] |
This file contains hidden or 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
//bad | |
var sequence = (function(data, temp){ | |
var len = data.length - 1; | |
for (var i = 0; i < len; ++i) { | |
temp.push(data[i+1] - data[i]); | |
} | |
return temp.join(','); | |
})((function(all, buf, user){ | |
var len = all.length; |
This file contains hidden or 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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<style> | |
body { | |
background: #333; | |
text-align: center; | |
} | |
#num { |
This file contains hidden or 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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
This file contains hidden or 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
#!/usr/bin/env python | |
# Get markdown module at: http://pypi.python.org/pypi/Markdown | |
from markdown import markdownFromFile | |
from string import Template | |
from datetime import datetime | |
import os | |
doc_path = 'document' |
This file contains hidden or 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
/** | |
* usage: | |
* $('div').draggable(); | |
* $('*').draggable(); | |
*/ | |
$.fn.draggable = function() { | |
var $document = $(document) | |
, mouse = { update: function(e) {this.x = e.pageX; this.y = e.pageY;} }; | |
This file contains hidden or 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
#!/usr/bin/env node | |
var http = require('http') | |
, fs = require('fs') | |
, url = require('url') | |
, exec = require('child_process').exec | |
, qs = require('querystring') | |
, path = require('path'); | |
This file contains hidden or 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
#!/usr/bin/env node | |
var md5 = require('./md5.js').md5 | |
, exec = require('child_process').exec | |
, username = process.argv[2] || '' | |
, password = process.argv[3] || '' | |
, getUrl = function(u, p) { | |
var href = '"http://xxx.xxx/xxx.php'; | |
return href + '?uid=1&username=' + u + '&passwd=' + p + '&time=100192&flag=1"'; | |
} |