View grpc-endpoints.md

Why gRPC & Endpoints

  • Endpoints might be great alternative to Mashery/Apigee with cloud integration
  • gRPC seems to be Google's standard for service to service communication. Services are gRPC, JSON API generated and proxied to gRPC service with endpoints (you essentially pass it your proto file and your openapi spec and it maps it together).
  • gRPC allows you to easily create libraries for all major languages
  • Extensible and flexible interface to apis

Try it out

View auth.py
# python auth.py /path/to/creds.json
# To install
# brew install python
# gcloud components install app-engine-python
# pip install --upgrade google-api-python-client
import sys
import json
import httplib2
import os
View auth.py
import sys
import json
import httplib2
import os
from oauth2client.service_account import ServiceAccountCredentials
if sys.argv < 2:
print "Usage auth [path-to-json]"
else:
keyPath = sys.argv[1]
View fibonacci.js
var getNextFibonacciAfter = (function() {
var fibonacciNumbers = [0, 1];
function nextFibonnacciIn(numbers) {
return numbers[numbers.length] + numbers[numbers.length - 1];
}
return function(number) {
var nextFibonacci;
View branch-diff.sh
# Shoot.. this is pointless actually. You can do this by `git diff origin/development...HEAD`
# Do a git diff between development, only on your changes by finding
# the last commit hash in your branch which is in development and diffing on that.
origin_development_hashes=$(git log --pretty=format:'%H' origin/development | tail -300)
for hash in `git log --pretty=format:'%H' | tail -300`; do;
[[ $origin_development_hashes =~ "$hash" ]] && found=$hash && break;
done;
if [ $found != "" ]; then
View data-loading-polymer.md

Declarative data loading in Polymer

  • Rather than writing a lot of imperative code how can we write more straightforward/simpler/consistent code, less prone to bugs.

Nextgen data loading components

  • Spawned off with needing to solve binding and data store issues when updgrading to Polymer 1.
    • Polymer 0.x used the Object observe to update bindings. We referenced a global store using basically an Object.assign function that updated elements referencing those objects.
    • Came up with an inf-store-observer component to listen for and bind updates
View calculator.html
<!DOCTYPE html>
<html>
<head>
<title>Calculator</title>
</head>
<body>
<basic-calculator></basic-calculator>
<template id="basicCalcTemplate">
<style>
View benchmark-template.js
/**
* Simple benchmark copy paste for browsers using Benchmark.js
* See their documentation: https://benchmarkjs.com/
* Edit the different suite add() sections below to change your tests or add new ones.
*/
var Script = function(url) {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = url;
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
View path-val.js
// via http://www.redotheweb.com/2015/09/18/declarative-imperative-js.html
function getValue(object, propertyName) {
if (!propertyName) throw new Error('Impossible to set null property');
return typeof object === 'undefined' ? undefined : object[propertyName];
}
function getNestedValue(object, propertyName) {
return propertyName.split('.').reduce(getValue, object);
}
View reduce.js
var input = [[2,6],[3,5],[7,21],[20,21]];
var expectedOutput = [[2,6],[7,21]];
var rangesOverlap = function(range1, range2) {
return (
(range1[1] >= range2[0] && range1[1] <=range2[1]) ||
(range1[0] <= range2[0] && range1[1] >= range2[0])
);
};