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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style>
.grid {
display: flex;
flex-direction: row;
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<dom-module id="x-example">
<style>
:host {
display: block;
}
</style>
<template>
<div id="text">x-example</div>
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
Base.isLightDom = function (node) {
return Polymer.dom(node).getOwnerRoot() === Polymer.dom(this).getOwnerRoot();
};
function refresh() {
var SCROLL_DIRECTION_UP = -1;
var SCROLL_DIRECTION_DOWN = 1;
var SCROLL_DIRECTION_NONE = 0;
var direction = SCROLL_DIRECTION_NONE;
var ratio = 0.5;
var delta = this.scrollTop - this.scrollPosition;
this.scrollPosition = this.scrollTop;
#!/bin/bash
# utils
# alias kp='pkill -f polyserve' - Kill all the `polyserve` processes
# alias p='~/polyserve.sh' - Polyserve
base=`basename "$PWD"`
port=$(( RANDOM % (1000) + 8000 ))
url="http://localhost:$port/components/$base/demo/index.html"
function randomNumber(min, max) {
min = parseInt(min, 10);
max = parseInt(max, 10);
if (min !== min) {
min = 0;
}
if (max !== max || max <= min) {
max = (min || 1) << 1; //doubling
} else {
max = max + 1;
@blasten
blasten / pre-commit
Created April 21, 2015 04:51
Pre-commit git hook
#!/usr/bin/env python
import os, sys
"""
Checks your git commit with JSHint. Only checks staged files
"""
def jshint():
errors = []
@blasten
blasten / rotatePicture.js
Created February 4, 2015 19:06
Rotates a matrix of pixels in place
function rotatePicture(matrix) {
if (matrix.length == 0 || matrix.length != matrix[0].length) {
return [];
}
var n = matrix.length;
var center = parseInt(n/2);
for (var i = 0; i < center; i++) {
var start = i;