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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>A simple SlideShow using :checked</title> | |
<style> | |
.slider-wrapper{ | |
overflow: hidden; | |
width: 300px; | |
height: 300px; |
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 flattenRecursive = function (arr) { | |
return arr.reduce(function (a,b) { | |
if (b instanceof Array) { | |
return a.concat(flattenRecursive(b)); | |
}else{ | |
return a.concat(b); | |
} | |
},[]); | |
} |
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 mysql = require("mysql"), | |
express = require("express"), | |
app = express(); | |
var connection = mysql.createConnection({ | |
host : "localhost", | |
user : "root", | |
password : "", | |
database : "node" | |
}); |
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 mysql = require("mysql"), | |
express = require("express"), | |
app = express(); | |
var connection = mysql.createConnection({ | |
host : "localhost", | |
user : "root", | |
password : "", | |
database : "node" | |
}); |
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 getQueryObj (query) { | |
query = query.substring(query.indexOf("?")+1,query.length); | |
var keys = query.split("&") , obj = {}; | |
for (var i = 0; i < keys.length; i++) { | |
var pair = keys[i].split("="); | |
obj[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); | |
} | |
return obj; | |
} | |
console.log(getQueryObj("http://example.com?x=hello&y=des%20t")); |
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 getQueryMatch (query,key) { | |
var regx = new RegExp(key+"=([^&]*)"); | |
return decodeURIComponent(query.match(regx)[1]); | |
} | |
console.log(getQueryMatch("http://example.com?x=hello&y=des%20t","y")); |
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
for (let i = 0; i < 10; i++) { | |
x += 10; | |
} | |
console.log(x); | |
try { | |
console.log(i); | |
} catch(e) { | |
console.log( |
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
// | |
// Super simple base64 encoding / decoding with node.js | |
// | |
var base64 = exports = { | |
encode: function (unencoded) { | |
return new Buffer(unencoded).toString('base64'); | |
}, | |
decode: function (encoded) { | |
return new Buffer(encoded, 'base64').toString('utf8'); |
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 cloneObject(obj) { | |
var clone = {}; | |
for(var i in obj) { | |
if(typeof(obj[i])=="object" && obj[i] != null) | |
clone[i] = cloneObject(obj[i]); | |
else | |
clone[i] = obj[i]; | |
} | |
return 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
function isArrayLike(obj) { | |
if (obj == null || isWindow(obj)) { | |
return false; | |
} | |
var length = obj.length; | |
if (obj.nodeType === 1 && length) { | |
return true; | |
} |
OlderNewer