Setup:
$ mongo
> use pubsub
> db.createCollection('messages', { capped: true, size: 100000 })
> db.messages.insert({})
var BASE64_MARKER = ';base64,'; | |
function convertDataURIToBinary(dataURI) { | |
var base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length; | |
var base64 = dataURI.substring(base64Index); | |
var raw = window.atob(base64); | |
var rawLength = raw.length; | |
var array = new Uint8Array(new ArrayBuffer(rawLength)); | |
for(i = 0; i < rawLength; i++) { |
web: node app.js | |
worker: node consumer.js |
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Looking At Underscore.js Templates</title> | |
</head> | |
<body> | |
<h1> | |
Looking At Underscore.js Templates |
'use strict'; | |
var phantom = require('node-phantom-simple') | |
; | |
phantom.create(function (err, ph) { | |
console.log('created phantom instance'); | |
ph.createPage(function(err, page) { | |
console.log('created page instance'); |
"use strict"; | |
var crypto = require("crypto"); | |
var EncryptionHelper = (function () { | |
function getKeyAndIV(key, callback) { | |
crypto.pseudoRandomBytes(16, function (err, ivBuffer) { | |
var keyBuffer = (key instanceof Buffer) ? key : new Buffer(key) ; |
<div class="row" id="box-search"> | |
<div class="thumbnail text-center"> | |
<img src="img/cafe.jpg" alt="" class="img-responsive"> | |
<div class="caption"> | |
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ab, quisquam?</p> | |
</div> | |
</div> | |
</div> |
# I am pasting that into setup steps | |
# binary provided by the amazing Codeship.io support | |
PHANTOMJS_URL="https://s3.amazonaws.com/codeship.io/checkbot/binaries/phantomjs_2.0.1" | |
set -e | |
rm -rf ~/.phantomjs | |
wget --continue "${PHANTOMJS_URL}" -O "${HOME}/cache/phantomjs" | |
ln -s "${HOME}/cache/phantomjs" "${HOME}/bin/" | |
chmod +x "${HOME}/bin/phantomjs" |
// http://stackoverflow.com/a/23797348/1150427 | |
xhr.open('POST', url, true); | |
xhr.responseType = 'arraybuffer'; | |
xhr.onload = function () { | |
if (this.status === 200) { | |
var filename = ""; | |
var disposition = xhr.getResponseHeader('Content-Disposition'); | |
if (disposition && disposition.indexOf('attachment') !== -1) { | |
var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/; |