// http://dmitry.baranovskiy.com/post/91403200
//## 1
if (!("a" in window)) {
var a = 1;
}
alert(a);
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 uuid() { | |
var s = []; | |
var hexDigits = "0123456789abcdef"; | |
for (var i = 0; i < 36; i++) { | |
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1); | |
} | |
s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010 | |
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01 | |
s[8] = s[13] = s[18] = s[23] = "-"; |
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
# install required packages | |
apt -y update | |
add-apt-repository ppa:webupd8team/java | |
apt -y update | |
apt -y install libcairo2-dev libjpeg-turbo8-dev libpng-dev libossp-uuid-dev libfreerdp-dev libpango1.0-dev libssh2-1-dev libtelnet-dev \ | |
libvncserver-dev libpulse-dev libssl-dev libvorbis-dev libwebp-dev git build-essential autoconf libtool oracle-java8-installer tomcat8 \ | |
tomcat8-admin tomcat8-common tomcat8-docs tomcat8-user maven postgresql-server-dev-9.5 postgresql-common postgresql-9.5 libpulse-dev \ | |
libvorbis-dev freerdp ghostscript wget pwgen | |
# create directories & files |
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
{"sig":"0baadc092f4c9c14f392581117daa8d87feaa6e457b09d9759f15c2a38af69553c82f678b4dc679ba99b3c4e8f5985c536a42d4c0ad6b020b299ecb967976dfa0","msghash":"f64ca939ace3a5c2c4d41162d2973b023e6ead80568fa7d0e266abe122b1b4f6"} |
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() { | |
'use strict'; | |
// 6.3.1 prototype chaining | |
// bad: if the super object's attribute is ref, like array, then it share in all sub object. | |
// bad: you can't pass arguments into the supertype constructer when sub type instance is being created. | |
(function() { | |
function SuperType() { | |
this.property = 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 fs = require('fs'); | |
var http = require('http'); | |
http.get('http://img31.mtime.cn/CMS/Gallery/2014/01/01/162652.23483887_160X160.jpg', function(res) { | |
console.log("Got response: " + res.statusCode); | |
var fw = fs.createWriteStream('./img2.jpg', {flags: 'w', encoding: 'binary', mode: '0666'}); | |
res.pipe(fw); | |
}).on('error', function(e) { | |
console.log("Got error: " + e.message); | |
}); |
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 fs = require('fs'); | |
var http = require('http'); | |
http.get('http://img31.mtime.cn/CMS/Gallery/2014/01/01/162652.23483887_160X160.jpg', function(res) { | |
console.log("Got response: " + res.statusCode); | |
var fw = fs.createWriteStream('./img2.jpg', {flags: 'w', encoding: 'binary', mode: '0666'}); | |
res.pipe(fw); | |
}).on('error', function(e) { | |
console.log("Got error: " + e.message); | |
}); |
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
a = _.reduce($("tr"), function(memo, v, i) { | |
var $el = $(v); | |
var obj = {}; | |
obj.id = $.trim($el.find('.end').text()); | |
obj.date = $el.find('td').eq(1).text(); | |
obj.red = $el.find('.STYLE13').html() && $el.find('.STYLE13').html().replace(/ /g, ' '); | |
obj.blue = $el.find('.STYLE12').text(); | |
if (obj.id !== '') { | |
memo.push(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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
<style type="text/css" media="all"> | |
#a {display: block;width: 200px; margin: 10px;border: 1px solid #f00;} | |
#span {display:block; width: 100px; margin: 20px; border: 1px solid #0f0;} | |
</style> | |
</head> |
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 copy(obj) { | |
// if (Object.prototype.toString.call(obj) !== '[object Object]') { | |
if (typeof obj !== 'object') { | |
return; | |
} | |
var ret = obj.constructor === Object ? {} : []; | |
for (var i in obj) { | |
if (obj[i].constructor === Array) { | |
ret[i] = Array.prototype.slice.call(obj[i]); |
NewerOlder