TLDR: Use for...of
instead of forEach()
in asynchronous code.
For legacy browsers, use for...i
or [].reduce()
To execute the promises in parallel, use Promise.all([].map(...))
/* | |
Minimal Facebook Messenger | |
========================== | |
1. Make a Fluid (http://fluidapp.com/) instance of https://facebook.com/messages/ | |
1. a. (You need to buy the paid version of Fluid to modify UserStyles) | |
2. Apply the below CSS as a Userstyles stylesheet | |
3. Like magic, you can now message without all the cruft of Full Facebook | |
var express = require('express'), | |
http = require('http'), | |
path = require('path'), | |
child_process = require("child_process"); | |
var app = express(); | |
// Server settings | |
app.set('port', process.env.PORT || 9999); | |
app.use(express.favicon()); |
# Note (November 2016): | |
# This config is rather outdated and left here for historical reasons, please refer to prerender.io for the latest setup information | |
# Serving static html to Googlebot is now considered bad practice as you should be using the escaped fragment crawling protocol | |
server { | |
listen 80; | |
listen [::]:80; | |
server_name yourserver.com; | |
root /path/to/your/htdocs; |
this.before(function(){ | |
var res = this.response; | |
if ('OPTIONS' == this.request.method) { | |
res.setHeaders(200,{ | |
'Content-Type': 'text/plain', | |
'Access-Control-Allow-Origin': '*', | |
'Access-Control-Allow-Methods': 'GET, PUT, POST, DELETE, OPTIONS', | |
'Access-Control-Allow-Headers': 'Content-Type, Authorization, X-Requested-With', | |
'Access-Control-Max-Age': 5184000 //2 months |
/** | |
* Simple, responsive tables with shadow hints | |
* Mashing http://www.maxdesign.com.au/2013/03/22/simple-responsive-table/ and http://lea.verou.me/2012/04/background-attachment-local/ | |
*/ | |
body { | |
margin: 0; | |
padding: 20px; | |
color: #000; | |
background: #fff; | |
font: 100%/1.3 helvetica, arial, sans-serif; |
(function($) { | |
function parseImagesFromCSS(doc) { | |
var i, j, | |
rule, | |
image, | |
pattern = /url\((.*)\)/, | |
properties = ['background-image', '-webkit-border-image'], | |
images = {}; | |
if (doc.styleSheets) { |