Skip to content

Instantly share code, notes, and snippets.

View blasten's full-sized avatar

Emmanuel Garcia blasten

  • c.ai
  • Palo Alto, CA
View GitHub Profile
export class SideBar extends HTMLElement {
static render({ name } = props) {
return <div>{name}</div>;
}
}
customElements.define('side-bar', SideBar);
export class ListView extends HTMLElement {
static render({ items } = props) {
@blasten
blasten / index.js
Last active August 22, 2016 22:44
Proxy
var express = require('express');
var request = require('request');
var dom5 = require('dom5');
var argv = require('minimist')(process.argv.slice(2));
var app = express();
const PORT = process.env.PORT || argv.p || argv.port;
function removeNode(node) {
if (node) {
dom5.remove(node);
@blasten
blasten / responsive-grid.html
Created March 21, 2016 21:28
Responsive grid using CSS custom properties
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Responsive Grid</title>
<style>
body {
<template is="app-shared-layout" id="cardIcons" if="[[isHover]]">
<div class="icons" title$="[[item.title]]">
<iron-icon icon="shopping-cart"></iron-icon>
<iron-icon icon="favorite"></iron-icon>
</div>
</template>
<dom-module id="x-test">
<template>
<div>[[test]]</div>
</template>
<script>
Polymer({
is: 'x-test',
properties: {
test: {
type: String,
<dom-module id="x-foo">
<div>test</div>
</dom-module>
<script>
Polymer.X_CONSTANT = 1;
Polymer({
is: 'x-foo',
properties: {
// Recursive depth first search
function RecursiveDFSTraversal(root, fn, fnArgs) {
if (!root) {
return;
}
fnArgs = fn(root, fnArgs);
for (var i = 0; fnArgs && i < root.children.length; i++) {
RecursiveDFSTraversal(root.children[i], fn, fnArgs);
}
}
// Iterative depth first search
function IterativeDFSTraversal(root, fn, fnArgs) {
var stack = [], nodeIdx = [], stackFrameArgs = [];
fnArgs = fn(root, fnArgs);
if (fnArgs) {
stack.push(root);
nodeIdx.push(0);
function checkSelector(node, selectors) {
if (selectors.length === 0) {
return false;
}
var currentSel = selectors.shift();
if (currentSel === '>') {
return checkSelector(node, selectors);
}
if (currentSel.charAt(0) === '.' && node.classList.contains(currentSel.substr(1))) {
return true;
function getElementsStampedByDomRepeat(domRepeat) {
return [].slice.call(domRepeat.parentElement.children).reduce(function(arr, child) {
if (domRepeat.modelForElement(child)) {
arr.push(child);
}
return arr;
}, []);
}