Skip to content

Instantly share code, notes, and snippets.

View Scarygami's full-sized avatar

Gerwin Sturm Scarygami

View GitHub Profile
@Scarygami
Scarygami / serve.js
Last active September 12, 2017 18:50
Cloud Function for differential serving on Firebase
const functions = require('firebase-functions');
const capabilities = require('browser-capabilities');
const rp = require('request-promise');
const request = require('request');
exports.serve = functions.https.onRequest((req, res) => {
const baseUrl = 'https://' + functions.config().firebase.authDomain;
// Fetch the hosted polymer.json to read the build configuration
return rp({
@Scarygami
Scarygami / firebase.json
Last active September 12, 2017 18:51
firebase.json for differential serving
{
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
@Scarygami
Scarygami / polymer.json
Last active September 12, 2017 14:33
Polymer.json for differential serving
{
...
"builds": [
{
"name": "modern-es6",
"browserCapabilities": ["es2015"],
"preset": "es6-unbundled",
"basePath": true
}, {
"name": "fallback-es5",
@Scarygami
Scarygami / my-name-polymer-1.x.html
Last active September 5, 2017 22:20
Samples and code snippets for my Polymer in Production article series
<!-- Polymer 1.x -->
<link rel="import" href="../polymer/polymer.html">
<dom-module id="my-name">
<template>
<style>
/* Amazing CSS to make my-name shine goes here */
</style>
<span>[[firstname]] [[lastname]]</span>
<template>
@Scarygami
Scarygami / dates.sql
Last active July 28, 2016 15:02
dynamic view for analysis services date dimension
-- Table-valued function to return a list of dates via a recursive query
CREATE FUNCTION [dbo].[dyn_dates](@DateFrom datetime, @DateTo datetime)
RETURNS @table TABLE (date_day datetime)
AS
BEGIN
WITH dates AS (
SELECT date_day = @DateFrom
UNION ALL
SELECT DATEADD(dd, 1, dates.date_day)
@Scarygami
Scarygami / gulp-bower.js
Last active August 29, 2015 14:26
Custom elements for Chrome Apps APIs
// take all bower dependencies
gulp.src(['bower_components/**/*'])
// run all html files through crisper for CSP
.pipe($.if('*.html', $.crisper()))
// put everything into ./{{dest}}/components/
.pipe(gulp.dest(path.join(destDir, 'components')));
gulp.watch(['dev/**'], $.batch(function (events, cb) {
var paths = [];
events.on('data', function (evt) {
paths.push(evt.path);
}).on('end', function () {
lr.changed({
body: {
files: paths
}
});
@Scarygami
Scarygami / request-data-binding1.html
Last active August 29, 2015 14:22
Data binding vs. event handling
<dom-module id="request-data-binding1">
<template>
<discovery-api-elements
name="plus" version="v1"></discovery-api-elements>
<google-signin
client-id="..."
scopes="..."
is-authorized="{{isAuthorized}}"></google-signin>
@Scarygami
Scarygami / with-debounce
Last active December 8, 2017 20:03
Polymer debounce sample
Polymer({
is: 'with-debounce',
properties: {
property1: {
type: String,
observer: '_doSomething'
},
property2: {
type: String,
observer: '_doSomething'
@Scarygami
Scarygami / hangout-app-new.html
Created May 18, 2015 13:55
hangout-app 0.9 release
<dom-element id="demo-hangout-app">
<template>
<hangout-app on-ready="readyCallback">
<h1>My Hangout App</h1>
</hangout-app>
</template>
</dom-element>
<script>
Polymer({