Skip to content

Instantly share code, notes, and snippets.

View dfmcphee's full-sized avatar

Dominic McPhee dfmcphee

View GitHub Profile
@joeytwiddle
joeytwiddle / async-await-forEach-alternatives.md
Last active March 26, 2024 16:12
Do not use forEach with async-await

Do not use forEach with async-await

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(...))

The problem

@ericelliott
ericelliott / essential-javascript-links.md
Last active March 28, 2024 23:01
Essential JavaScript Links
@cmod
cmod / minimal_fb_messenger.css
Last active February 15, 2022 19:11
Minimal Facebook Messenger for Fluid
/*
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
@velsa
velsa / app.js
Created March 25, 2014 15:43
Express server used to launch ffmpeg, transcode stream from peerflix and serve it to HTML5 video tag
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());
@Stanback
Stanback / nginx.conf
Last active February 4, 2022 18:05
Example Nginx configuration for serving pre-rendered HTML from Javascript pages/apps using the Prerender Service (https://github.com/collectiveip/prerender).Instead of using try_files (which can cause unnecessary overhead on busy servers), you could check $uri for specific file extensions and set $prerender appropriately.
# 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;
@doapp-ryanp
doapp-ryanp / gist:6011897
Created July 16, 2013 19:35
geddy cors
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
@seancurtis
seancurtis / dabblet.css
Created March 22, 2013 00:27
Simple, responsive tables with shadow hints
/**
* 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) {