#createElement(element,attribute,inner);
use:
createElement("tag","[attr:val][attr:val]",[element1,"some text",element2,element3,"or some text again :)"]);
basic:
replace-in-selector($what, $with = '') | |
/{replace($what, $with , selector())} | |
{block} | |
root-selector() | |
+replace-in-selector('^(\S+).*', '$1') | |
{block} | |
.foo | |
.bar |
#createElement(element,attribute,inner);
use:
createElement("tag","[attr:val][attr:val]",[element1,"some text",element2,element3,"or some text again :)"]);
basic:
/* | |
takes the x,y coordinates, the number of spikes, the inner and the outer radius of the spikes | |
*/ | |
function drawStar(ctx,cx,cy,spikes,r0,r1){ | |
var rot=Math.PI/2*3,x=cx,y=cy,step=Math.PI/spikes | |
ctx.strokeSyle="#000"; | |
ctx.beginPath(); |
Simple, unobtrusive add-on to support String refs in Preact, without needing to pull in preact-compat.
Calling linkRef(componentInstance, refName)
returns a "ref proxy" function, which sets this.refs[refName]
when called.
import { h, Component } from 'preact';
import linkRef from './linked-ref';
function inferInputModel() { | |
if (window.navigator.msPointerEnabled) { | |
return 'pointer'; | |
} else if (window.ontouchstart !== undefined) { | |
return 'touch'; | |
} else { | |
return 'unknown'; | |
} | |
} |
/* | |
array implementation of a binary heap, example usage: | |
// can optionally provide a comparison function, a function for a max | |
// heap is the default if no comparison function is provided | |
var bh = binaryHeap(); | |
bh.push(5); | |
bh.push(34); | |
bh.push(16); | |
var max = bh.pop(); // 34 |
nodejs terminal UI tools
Inquirer A collection of common interactive command line user interfaces. Used by yeoman
terminal-menu used in rvagg/workshopper learnyounode...
cli-color used in rvagg/workshopper learnyounode...
blessed A curses-like library for node.js.
Function.prototype.bind=Function.prototype.bind||function(b){if(typeof this!=="function"){throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");}var a=Array.prototype.slice,f=a.call(arguments,1),e=this,c=function(){},d=function(){return e.apply(this instanceof c?this:b||window,f.concat(a.call(arguments)));};c.prototype=this.prototype;d.prototype=new c();return d;}; |
window.mobileAndTabletcheck = function() { | |
var check = false; | |
(function(a) { | |
if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) || | |
if (window.mobileAndTabletcheck == true) |
// Have some complicated non-React widgets that manipulate DOM? | |
// Do they manage a list of DOM elements? Here's how to wrap it | |
// into a React component so you can "constantly rerender" it. | |
// A dumb non-react widget that manually manage some DOM node that | |
// represent a list of items | |
function NonReactWidget(node) { | |
this.node = node; | |
} |