Skip to content

Instantly share code, notes, and snippets.

@wejrowski
wejrowski / grpc-endpoints.md
Last active June 13, 2018 17:11
gRPC + Endpoints notes

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

@wejrowski
wejrowski / auth.py
Created July 13, 2017 19:55
Get google auth tokens from json
# 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
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]
@wejrowski
wejrowski / fibonacci.js
Last active April 3, 2017 20:15
Quiz: next fibonacci number
var getNextFibonacciAfter = (function() {
var fibonacciNumbers = [0, 1];
function nextFibonnacciIn(numbers) {
return numbers[numbers.length] + numbers[numbers.length - 1];
}
return function(number) {
var nextFibonacci;
@wejrowski
wejrowski / branch-diff.sh
Last active October 21, 2016 17:56
Git diff branch changes
# 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
@wejrowski
wejrowski / data-loading-polymer.md
Last active September 16, 2016 21:33
Declarative data loading in Polymer

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
@wejrowski
wejrowski / calculator.html
Last active March 14, 2021 18:59
Web component + shadow DOM
<!DOCTYPE html>
<html>
<head>
<title>Calculator</title>
</head>
<body>
<basic-calculator></basic-calculator>
<template id="basicCalcTemplate">
<style>
@wejrowski
wejrowski / benchmark-template.js
Last active March 23, 2016 18:34
Benchmark template
/**
* 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);
@wejrowski
wejrowski / path-val.js
Last active October 28, 2015 19:10
Get path value
// 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);
}