Skip to content

Instantly share code, notes, and snippets.

@jcmoore
jcmoore / tern_scope_copy.html
Created April 6, 2014 21:38
extra lookup for tern.js
<html>
<head>
<script>
window.onload = (function () {
var infer = tern;
var code = document.querySelector(".javascript").innerHTML.trim();
var cx = infer.withContext(new infer.Context(), function () {
//infer.findExpressionAround(cx.topScope.node, 293062, 294655, cx.topScope).node.body.scope
//infer.findExpressionAround(cx.topScope.node, 29037, 29271, cx.topScope).node.body.scope
var ccx = infer.cx();
@jcmoore
jcmoore / fennel.js
Last active August 29, 2015 14:00
Fennel.js prototype -- useful for making "curries"
var Fennel = (function FennelMake () {
var Curry = function Curry () {
};
Curry.prototype.method = {};
Curry.prototype.context = {};
Curry.prototype.params = (function paramsMake () {
/*
* grunt-git-tag-parse
* https://github.com/dlasky/grunt-git-tag-parse
*
* Copyright (c) 2014 Dan Lasky
* Licensed under the MIT license.
*/
'use strict';
@jcmoore
jcmoore / loco.js
Created May 7, 2014 07:17
loco.js -- reusable, chainable, multiple, return values
var Loco = (function LocoMake () {
var nadda = {},
empty = {}
caboose = null,
Railcar = function Railcar () {
this.value = nadda;
this.deref = this;
};
@jcmoore
jcmoore / CustomElements-src-CustomElements.js
Last active August 29, 2015 14:01
polymer shadow DOM missed events
/*
* Copyright 2013 The Polymer Authors. All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
*/
/**
* Implements `document.register`
* @module CustomElements
*/
@jcmoore
jcmoore / ShadowDOM-src-wrappers-events.js
Created May 20, 2014 20:12
polymer (over-)eager event triggering
// Copyright 2013 The Polymer Authors. All rights reserved.
// Use of this source code is goverened by a BSD-style
// license that can be found in the LICENSE file.
(function(scope) {
'use strict';
var forwardMethodsToWrapper = scope.forwardMethodsToWrapper;
var getTreeScope = scope.getTreeScope;
var mixin = scope.mixin;
@jcmoore
jcmoore / app.js
Last active August 29, 2015 14:03 — forked from miguel250/app.js
requirejs.config({
"baseUrl": "",
"paths": {
"ZeroClipboard": "http://cdnjs.cloudflare.com/ajax/libs/zeroclipboard/2.1.1/ZeroClipboard"
}
});
requirejs(['ZeroClipboard'], function(ZeroClipboard) {
var client = new ZeroClipboard( document.getElementById("copy-button") ),
bridge = document.querySelector("#"+ZeroClipboard.config().swfObjectId),
@jcmoore
jcmoore / gist:44b117ce6cd6ab4630f3
Created July 11, 2014 22:09
Polymer DOM selection over many divs (hangs on FFv30)
<html class="no-js -webkit-" lang="en"><!--<![endif]-->
<!-- Problem avoided if platform.js is not loaded -->
<script language="javascript" src="http://cdnjs.cloudflare.com/ajax/libs/polymer/0.3.3/platform.js"></script>
<script type="text/javascript">
// version of platform.js does not seem to matter (in Firefox -- v30 for instance)
@jcmoore
jcmoore / querySelector.js
Last active August 29, 2015 14:04
querySelector.js proposed patch for Polymer/polymer#629
// Copyright 2013 The Polymer Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
(function(scope) {
'use strict';
var HTMLCollection = scope.wrappers.HTMLCollection;
var NodeList = scope.wrappers.NodeList;
@jcmoore
jcmoore / replay.js
Last active August 29, 2015 14:04
Auto-replay video
//
window.replay = (function (initial) {
var interval = null;
return (function repeat (setting) {
if (setting && !interval) {
interval = setInterval(function () {
var button = document.querySelector('[role="button"][aria-label="Replay"]');
event;
if (button) {