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
/** | |
* refer:easyloader.js | |
*/ | |
function loadJs(url, callback){ | |
var done = false; | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.language = 'javascript'; | |
script.src = url; | |
script.onload = script.onreadystatechange = function(){ |
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 obj = { | |
"first":"first", | |
"zoo":"zoo", | |
"2":"2", | |
"34":"34", | |
"3.4":"3.4", | |
"1":"1", | |
"second":"second" | |
}; | |
for (var i in obj) { |
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
input[type="reset"]::-moz-focus-inner, | |
input[type="button"]::-moz-focus-inner, | |
input[type="submit"]::-moz-focus-inner, | |
input[type="file"] > input[type="button"]::-moz-focus-inner{ | |
border:none;padding:0; | |
} |
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 len = 4; | |
while(len--){ | |
setTimeout(function(){ | |
alert(len); | |
},0); | |
alert(len); | |
} | |
// out: 3,2,1,0,-1,-1,-1,-1 | |
var len = 4; |
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
// | |
// Regular Expression for URL validation | |
// | |
// Author: Diego Perini | |
// Updated: 2010/12/05 | |
// License: MIT | |
// | |
// Copyright (c) 2010-2013 Diego Perini (http://www.iport.it) | |
// | |
// Permission is hereby granted, free of charge, to any person |
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
#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 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
// Tiny Raytracer (C) Gabriel Gambetta 2013 | |
// ---------------------------------------- | |
// | |
// Configuration and scene | |
// | |
// Size of the canvas. w is also reused as a "big constant" / "+infinity" | |
var w = 600; | |
// Sphere: radius, [cx, cy, cz], R, G, B, specular exponent, reflectiveness | |
// R, G, B in [0, 9], reflectiveness in [0..9]. |
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 createHTML(object,map){ | |
var result = ""; | |
for(var k in object){ | |
result += map[k] + ':' + object[k] + '<br />'; | |
} | |
return '<p>' + result + "</p>"; | |
} | |
var map = { | |
name: '姓名', |
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
/** | |
* @author Dongxu Huang \ shuke | |
*/ | |
var isAlpha = function(str) { | |
return/[a-zA-Z']+/.test(str) | |
}; | |
document.addEventListener("mousemove", update_mouse_pos, true); | |
document.addEventListener("mouseup", on_mouse_up, true); | |
document.addEventListener("mousedown", on_mouse_down, true); |
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 getSuffixIcon = function(type){ | |
var icon ='unknow'; | |
var suffix = { | |
image:['jpg','png','gif','jpeg'], | |
doc:['doc','docx'], | |
rar:['rar','zip','tar','gz','7z','tar.gz'], | |
xls:['csv','xls'] | |
} | |
for(var k in suffix){ | |
if($.inArray(type, suffix[k]) > -1){ |