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
/** | |
* Replace any ocurrences of {{dimsum}} with generated text. | |
*/ | |
dimsum.parse = function(root) { | |
var reg = /{{dimsum[:]?([pst0-9]*)}}/ig, | |
root = root || document.getElementsByTagName('body')[0], | |
command = ''; | |
// If root is just a string, then return a string with replacement |
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
Windows.Storage.ApplicationData.current.localFolder.createFileAsync("example.svg", Windows.Storage.CreationCollisionOption.replaceExisting) | |
.then(function(storageFile) { | |
var serializer = new XMLSerializer() | |
, xmldoc = new Windows.Data.Xml.Dom.XmlDocument() | |
, xmlLoadSettings = new Windows.Data.Xml.Dom.XmlLoadSettings() | |
, svgnode = document.querySelector('.container > svg') | |
, svgstr = serializer.serializeToString(svgnode) | |
xmlLoadSettings.prohibitDtd = false; |
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
/** Native NodeJS */ | |
var http = require('http') | |
, server = http.createServer(function(req) { | |
console.log(req.headers['user-agent']); | |
}); | |
server.listen(3000, 'localhost'); | |
/** NodeJS with Express */ | |
var express = require('express') |
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
/** User-agent pattern matching */ | |
var browser = 'unknown' | |
, version = 'unknown' | |
, patterns = { | |
android: /android\s([0-9.]*)/i | |
chrome: /chrome\/([0-9.]*)/i, | |
firefox: /firefox\/([0-9.]*)/i, | |
ie: /msie\s([0-9.]*)/i, | |
ipad: /ipad.version\/([0-9.]*).safari/i, | |
iphone_4: /iphone\sos\s4.version.mobile\/([0-9.]*).safari/i, |
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
/** NodeJS with Express */ | |
var express = require('express') | |
, http = require('http') | |
, app = express(); | |
http.createServer(app).listen(3000); | |
app.get('/', function(req, res) { | |
console.log(req.get('user-agent')); | |
}); |
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
if ('document' in this) { | |
this.document.addEventListener('DOMContentLoaded', function() { | |
dimsum.parse(document.getElementsByTagName('body')[0]); | |
}); | |
} |
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
; (function () { | |
var Controls = Controls || {}; | |
var fallback = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIW2N81d/4HwAHYAL7mbvoAwAAAABJRU5ErkJggg=='; | |
var classname = 'deferred-img'; | |
Controls.Image = function (node, options) { | |
this.state = 'ready'; | |
this.node = node || document.createElement('figure'); |
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
ec2.describeInstances(params, handleResponse); | |
function handleResponse(err, data){ | |
if (err) { | |
console.log("Error", err); | |
return; | |
} | |
else { | |
var status = data.Reservations[0].Instances[0].State; |
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
# -i: The interface to listen on | |
# -s: Setting snaplen to 0 sets it to the default of 65535 | |
# -B: Buffer size in KiB | |
# -w: File to write packets to | |
tcpdump -i en1 -s 0 -B 524288 -w out.pcap dst port 8080 |