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() { | |
var cache = {}; | |
this.tmpl = function(str, data) { | |
cache[str] = cache[str] || | |
new Function('data', [ | |
'var _p="";\nwith(arguments[0]||{}){\n_p+="', | |
str.replace(/"/g, '\\$&') | |
.replace(/[\r\n]/g, '') | |
.replace(/<%([^\w\s\}\)]*)\s*(.*?)\s*%>/g, function(match, mark, code) { | |
if (mark === '=') return '"+(' + code + ')+"'; |
The current Push API Draft specifies a system that has no notion of push channel persistence. Further, it does not include push message payloads, a feature that many developers want.
This gist outlines an API which:
- integrates with the Service Worker to enable delivery of push messages to applications which do not have visible tabs
- enables a JSON-formatted body of content
- guards access to registration for pushes on potential user consent
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
#!/usr/bin/env python | |
""" | |
JSON encoder/decoder adapted for use with Google App Engine NDB. | |
Usage: | |
import ndb_json | |
# Serialize an ndb.Query into an array of JSON objects. | |
query = models.MyModel.query() |
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 queue = [ | |
'https://peerj.com/articles/1.json', | |
'https://peerj.com/articles/2.json', | |
'https://peerj.com/articles/3.json', | |
]; | |
var run = function() { | |
var xhr = new XMLHttpRequest; | |
xhr.open('GET', queue.shift()); | |
xhr.responseType = 'json'; |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
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 all the Go tools and godep tool | |
# Location of gobin is based on installation by OS X Homebrew | |
sudo -u admin GOPATH=/tmp GOBIN=/usr/local/opt/go/bin go get -u golang.org/x/tools/cmd/... | |
sudo -u admin GOPATH=/tmp GOBIN=/usr/local/opt/go/bin go get -u github.com/tools/godep |
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
'use strict'; | |
// simple express server | |
var express = require('express'); | |
var app = express(); | |
var router = express.Router(); | |
app.use(express.static('public')); | |
app.get('/', function(req, res) { | |
res.sendfile('./public/index.html'); |
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
node_modules/ |