Skip to content

Instantly share code, notes, and snippets.

function InheritWithExtend (parentPrototype, extendedPrototype) {
var childPrototype = Object.create(parentPrototype);
Object.getOwnPropertyNames(extendedPrototype).forEach(function(property) {
Object.defineProperty(
childPrototype,
property,
Object.getOwnPropertyDescriptor(
extendedPrototype,
property
)
@cdata
cdata / ajax-text.html
Last active August 29, 2015 14:17
Binding example
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../core-ajax/core-ajax.html">
<dom-module id="x-ajax-text">
<!-- We bind the core-ajax `lastResponse` to the `content` property. This
property is not actually published by `x-ajax-text`, but because it is
specified in the template it will be bindable elsewhere in the template -->
<core-ajax id="ajax" url="./content.txt" last-response="{{content}}" auto></core-ajax>
<!-- Here we bind `content` in another place, which will be effectively
equivalent to binding `this.$.ajax.lastResponse`. -->

Quick Element

I made a "quick-element" element for my core-focusable demo, so that I could quickly prototype the demo element inline in the main document instead of in a separate file.

Does this seem useful as a more general-purpose element? If so, where should it live?

@cdata
cdata / core-meta-proposal.md
Last active December 18, 2015 08:34
<core-meta> proposal

In 0.5

Implementing <core-meta>:

<link rel="import" href="../core-meta/core-meta.html">
<polymer-element name="core-foo" extends="core-meta">
  <script>
    Polymer('core-foo', {
      ready: function () {
@cdata
cdata / fixture-unfixture.js
Last active August 29, 2015 14:14
Just fixture
function fixture (id) {
var fixtureElement = document.getElementById(id);
fixtureElement.create();
afterEach(function () {
fixtureElement.restore();
});
return fixtureElement.getFixturedDom();
@cdata
cdata / id-parse.js
Created December 4, 2014 05:42
Slow and dirty file parsing for fun and profit
#!/usr/bin/env node
var fs = require('fs');
var basePath = process.cwd();
var expression = process.argv[2] || '(9[0-9]{5,})';
function absolutePath (somePath) {
return require('path').resolve(somePath);
}
@cdata
cdata / post.js
Last active August 29, 2015 14:06
Another contrived script
/* Usage: node ./post.js $URL_TO_POST_TO */
var https = require('https');
var url = require('url');
var locationToPostTo = process.argv[2];
var dataToPost = {
foo: 'bar'
};
var dataString = JSON.stringify(dataToPost);
@cdata
cdata / epoch.js
Created September 23, 2014 21:20
Contrived JS
var now = Date.now();
var hourFromNow = now + 3600;
console.log(now);
console.log(hourFromNow);
@cdata
cdata / webgl-test.js
Created September 19, 2014 05:18
WebGL-oriented Metrics Collector
;(function () {
'use strict';
function now () {
if (window.performance && typeof window.performance.now !== 'undefined') {
return window.performance.now();
}
return +new Date();
}
@cdata
cdata / buffer.js
Created August 6, 2014 21:24
ES6 Sample
import { Primitive } from 'primitive';
let Buffer = Primitive.extend((Super) => {
return {
init (ArrayType, itemSize, pageSize) {
this.used = new Set();
this.freeByteIndices = [];
this.pages = [];
this.itemSize = itemSize;