Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<link rel="import" href="https://cdn.rawgit.com/Polymer/polymer/v0.9.1/polymer.html">
</head>
<body>
<rtc-peer-connection is-caller allow-data-channels auto-connect log>
<rtc-signal-channel url="wss://example.com"></rtc-signal-channel>
// Base behavior ("super class"):
var BehaviorFoo = {
baz: function() {
console.log('foo');
}
};
// Inheriting behavior ("sub class"):
var BehaviorFooBar = {
baz: function() {
// Example:
// < Flatten([1, 2, 3, [4, 5, [6]], [7, 8, 9], 10)
// > [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
function Flatten() {
var args = Array.prototype.slice.call(arguments);
var list = [];
var arg;
while (args.length) {
@cdata
cdata / document-fun.html
Created May 13, 2015 02:56
A fun way to mess with documents before other scripts execute.
<script>
document.addEventListener('DOMContentLoaded', function() {
var template = document.createElement('template');
template.innerHTML = RawDocument.textContent;
// Do what you will w/ document here..
template.content.querySelector('title').textContent = 'Bar';
template.content.querySelector('p').textContent = 'Foo';
template.content.querySelector('script').textContent = 'console.log("This document is owned.");';
Verifying I am +cdata on my passcard. https://onename.com/cdata
<link rel="import" href="https://rawgit.com/Polymer/polymer/v0.9.0-rc.1/polymer.html">
<style is="custom-style">
* {
--test: {
background: red;
}
}
</style>
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/iron-ajax/iron-ajax.html">
<dom-module id="kite-map" attributes="foo">
<template>
<div>{{lat}}</div>
<iron-ajax auto
url="http://127.0.0.1/data/2.5/station/find"
params='{{updateSensorData(lat, lng, cnt)}}'
last-response="{{ajaxResponse}}">
<!--
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
-->
<link rel="import" href="../polymer/polymer.html">
<script>
@cdata
cdata / polymer-bonds.js
Last active August 29, 2015 14:18
A covalence scheme for Polymer 0.8
var PolymerLifecycleMethods = [
'created',
'ready',
'attached',
'detached',
'registered'
];
var PolymerObjectProperties = [
'properties',
!function(t,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():(t.Promise=t.Promise||e(),t.PromisePolyfill=e())}(this,function(t){return function(){function e(t){this.state=e.state.PENDING,this.promise=t,this.result=null,this.pendingFulfillmentHandlers=[],this.pendingRejectionHandlers=[]}function n(t){var n=this.__deferred__=new e(this);if(!t)throw new Error("Promise constructor takes a function argument");t(c(n.resolve,n),c(n.reject,n))}var i=function(t){return!(!t||"function"!=typeof t)},r=function(t){return!!(t instanceof n)},o=function(t){return!!t&&t.hasOwnProperty("length")&&!t.propertyIsEnumerable("length")},s=function(t){var e;return null===t?!1:(e=typeof t,!("object"!==e&&"function"!==e||!("then"in t)))},u=function(){return t.setImmediate?t.setImmediate:t.requestAnimationFrame?t.requestAnimationFrame:function(e){t.setTimeout(e,0)}}(),c=function(t,e){return t.bind?t.bind(e):function(){return t.apply(e,arguments)}};return e.state={PENDING:"pending",FULFILL