Skip to content

Instantly share code, notes, and snippets.

View isorna's full-sized avatar
😃
New projects on the horizon

Alvaro Isorna isorna

😃
New projects on the horizon
View GitHub Profile
@Dabolus
Dabolus / Deploying PWA Starter Kit to Firebase.md
Last active June 26, 2020 01:39
A simple guide that explains how to deploy PWA Starter Kit to Firebase

Note: this guide explains step by step how to add Firebase to PWA Starter Kit.

If you already have some Firebase knowledge and you just want to get everything ready out of the box, you might want to checkout the Firebase branch on the PWA Starter Kit repo, that already contains all the needed files.

Deploying prpl-server to Firebase

Firebase Hosting alone is not sufficient for hosting the prpl-server build since it requires some server-side processing of the user agent string. Instead, you will have to use Firebase Functions for that.

  1. Sign up for a Firebase account
@davideast
davideast / rules.bolt
Last active December 15, 2015 18:33
Securing user data - Bolt rules
isUser(uid) = auth != null && auth.uid == uid;
type Post {
uid: String;
title: String;
description: String;
timestamp: Number;
}
type User {
@ebidel
ebidel / unused-html-imports-bookmarket.js
Last active March 16, 2020 03:45
Bookmarklet to help prune unnecessary HTML Imports loaded on a page.
javascript:(function(){'use strict';var _temporalUndefined={};function _temporalAssertDefined(val,name,undef){if(val===undef){throw new ReferenceError(name+' is not defined - temporal dead zone');}return true;}(function(){'use strict';var els=_temporalUndefined;var allCustomElements=_temporalUndefined;var polymerRegisteredElements=_temporalUndefined;var diff=_temporalUndefined;function isCustomEl(el){return el.localName.indexOf('-')!=-1||el.getAttribute('is');}els=[].slice.call(document.querySelectorAll('html /deep/ *')).filter(function(el){return isCustomEl(el);}).map(function(el){return el.getAttribute('is')||el.localName;});allCustomElements=new Set(_temporalAssertDefined(els,'els',_temporalUndefined)&&els);polymerRegisteredElements=Polymer.telemetry.registrations.map(function(el){return el.is;}).filter(function(name){var blacklist=_temporalUndefined;blacklist=['dom-template','array-selector','custom-style'];return(_temporalAssertDefined(blacklist,'blacklist',_temporalUndefined)&&blacklist).indexOf(name)==
@alexcastillo
alexcastillo / angular-hack.js
Last active March 3, 2016 02:10
Hacking AngularJS in oder to broadcast a custom event for directives
/**
* AngularJS hack - This way we can get and decorate all custom directives
* in order to broadcast a custom directive events: $directiveAdd
**/
// This is where all the custom directives will be stored
var $directives = [];
var originalModule = angular.module;
angular.module = function () {
var module = originalModule.apply(this, arguments);
var originalDirective = module.directive;
@sararob
sararob / data-structure.js
Last active April 26, 2022 22:21
Role-based security in Firebase
/*
This example shows how you can use your data structure as a basis for
your Firebase security rules to implement role-based security. We store
each user by their Twitter uid, and use the following simplistic approach
for user roles:
0 - GUEST
10 - USER
20 - MODERATOR
/*global Firebase, google, $, GeoFire */
(function () {
"use strict";
var map, previousInfowindow, ref, center, radiusInKm,
markers = {},
lines = {};
radiusInKm = 0.5;
ref = new Firebase("https://publicdata-parking.firebaseio.com/san_francisco");
center = [37.78565219391501, -122.4058404513338];
@oalami
oalami / earthquakes.js
Last active March 12, 2021 13:27
Global Earthquakes in Realtime using Firebase Open Data Sets
const CONTINENTS = ["europe", "asia", "africa", "north_america", "south_america", "antartica", "oceanic"];
var map;
var previousInfowindow;
var ref = new Firebase("https://publicdata-earthquakes.firebaseio.com/by_continent/");
function mapQuake(snapshot) {
var quake = snapshot.val();
var myLatlng = new google.maps.LatLng(quake.location.lat,quake.location.lng);
map.setCenter(myLatlng);
@octocat
octocat / .gitignore
Created February 27, 2014 19:38
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@katowulf
katowulf / extend.js
Created September 17, 2013 18:06
A simple extend function for JavaScript
function extend(base) {
var parts = Array.prototype.slice.call(arguments, 1);
parts.forEach(function (p) {
if (p && typeof (p) === 'object') {
for (var k in p) {
if (p.hasOwnProperty(k)) {
base[k] = p[k];
}
}
}
@drbobbeaty
drbobbeaty / unpinned_merchants.html
Created September 25, 2012 13:57
Example of creating a CSV download from Google Visualization Table
<html>
<head>
<title>Unpinned Merchants</title>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript' src='zingchart/resources/jquery.min.js'></script>
<script type='text/javascript'>
google.load('visualization', '1', {packages:['table']});
google.setOnLoadCallback(reload_executions);
// set up the fixed locations and paths for this metric visualization.
// we need to be able to pick the server (prod, uat, dev).