Skip to content

Instantly share code, notes, and snippets.

View developit's full-sized avatar
🦊
write, the codes

Jason Miller developit

🦊
write, the codes
View GitHub Profile
template=function(l){var q={},r={_default:function(b){return this[b.value&&b.value.splice?"each":"if"](b)},each:function(b){var h="",a,f=b.value;for(a in f)f.hasOwnProperty(a)&&(h+=l(b.content,f[a],void 0));return h},"if":function(b){return b.value?l(b.content,b.fields,b.overrides):""},"else":function(b){return b.value?"":l(b.content,b.fields,b.overrides)},unless:function(b){return this["else"](b)}};return l=function(b,h,a){var f=/\{\{\{?([#\/\:]?)([^ \{\}\|]+)(?: ([^\{\}\|]*?))?(?:\|([^\{\}]*?))?\}?\}\}/g,
g="",c,d,e,m,k=[];a={fields:h||{},overrides:a||q};a.path=(a.overrides.__path__?a.overrides.__path__+".":"")+a.overrides.__key__;for(f.lastIndex=0;d=f.exec(b);){0===k.length&&(g+=b.substring(c||0,f.lastIndex-d[0].length));c=d[1];if(!c||"#"!==c&&":"!==c&&"/"!==c){if(c=d[2],0===k.length)if(e=a.overrides[c]||h[c],null==e)g+=d[0];else{c="{"!==d[0].charAt(2);if(d[4])for(m=d[4].split("|"),d=0;d<m.length;d++)if(helpers.hasOwnProperty(m[d])){"html"===m[d]&&(c=!1);var n=m[d].split(":"),p=helpers[n[0]];"string"===
ty
@developit
developit / placeholder.html
Last active August 29, 2015 14:16
Placeholders for all
<input tpl="url" placeholder="http://">
<script src="placeholder.js"></script>
<script>[].map.call(document.querySelectorAll('[placeholder]'), placeholder);</script>
@developit
developit / warsting.ino
Last active August 29, 2015 14:17 — forked from zsup/warsting.ino
/** Slay and pillage an unprotected network! ...oh, we can't do that?
* Ok, let's publish an event instead, to a backdrop of flashing lights
* and clashing of metal on metal.
*/
void vanquishOpenNetwork() {
if (!openNetworkCount || !strongest.rssi) {
return;
}
// allow the system to control the LED so we can see cloud connection progress
@developit
developit / atom-scrollbars.less
Created March 25, 2015 20:40
Lovely scrollbars for Atom.
atom-text-editor::shadow,
.tree-view-resizer {
::-webkit-scrollbar {
width: 2px;
height: 2px;
}
::-webkit-scrollbar-track {
background: #1a2127;
}
::-webkit-scrollbar-thumb {
@developit
developit / custom-elements.js
Last active August 29, 2015 14:22
Custom Elements
(function() {
var elements = {};
function scan() {
[].forEach.call(
document.querySelectorAll('template[element]'),
function(el) {
var name = el.getAttribute('element'),
script = el.content.querySelector('script'),
js = script.innerHTML;
@developit
developit / set-immediate.js
Last active August 29, 2015 14:23
setImmediate multiple implementations
var setImmediate = (function(f, q, p, reg) {
q = [];
f = document.createElement('iframe');
f.style.cssText = 'position:absolute;top:-999em;left:0;width:1px;height:1px;';
document.body.appendChild(f);
function done() {
for (var i=0; i<q.length; i++) q[i]();
q.length = 0;
}
p = [
@developit
developit / autocomplete.js
Last active August 29, 2015 14:23 — forked from pk11/reactjs.js
/**
* Our component structure will look like the following:
* - WikiBox
* -- AutoCompleteBox
* --- AutoComplete
*/
/** Renders a single entity coming from wikipedia */
class AutoComplete extends React.Component {
render() {
@developit
developit / es-component.js
Created June 17, 2015 20:01
React ES6 Components
import React from 'react';
export class Component extends React.Component {
constructor(...args) {
super(...args);
this.generateBindings();
if (typeof this.init==='function') {
this.init();
}
}
/**
* var jpr = new JSONPRequest();
* jpr.onload = (...data) => {
* console.log(data);
* };
* jpr.open('GET', 'some-url?callback={{callback}}');
* jpr.send();
*/