This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('namespace.directives', []).directive('placeholder', ['$timeout', function($timeout) { | |
var i = document.createElement('input'), | |
support = ('placeholder' in i); | |
if (support) return {}; | |
return { | |
restrict: 'A', | |
link: function(scope, elm, attrs) { | |
if (attrs.type === 'password') { | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(w) { | |
var Matrix3D = {}; | |
Matrix3D._deg2rad = function(deg) { | |
return deg * (Math.PI / 180); | |
}; | |
Matrix3D.create = function() { | |
var out, args = Array.prototype.slice.call(arguments); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(d) { | |
var tags = 'h1 h2 h3 h4 h5 h6 p div'.split(' '); | |
var elems = []; | |
for (var t in tags) { | |
elems = elems.concat(Array.prototype.slice.call(d.getElementsByTagName(tags[t]))); | |
} | |
for (var e in elems) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _listeners = {}; | |
function on() { | |
var args = [].slice.call(arguments); | |
var ev = args[0], | |
fn = args[1], | |
scope = args[2]; | |
_listeners[ev] = _listeners[ev] || []; | |
_listeners[ev].push({ fn : fn, scope : scope }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A quick implementation of this idea in JavaScript. | |
* https://www.reddit.com/r/shittyprogramming/comments/2sxbh9/program_with_all_obscure_c_features_ideas/cnu1qpm | |
*/ | |
function angrify(fn) { | |
return function() { | |
try { | |
fn.apply(this, arguments); | |
} catch(e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
var audio = new Audio(); | |
audio.src = 'data:audio/mp3;base64,SUQzAwAAAAAAEFRDT04AAAAGAAAAT3RoZXL/+pDAv8oAABVeLuYZKgACvhglw7WgAfBYg33wCvAG/wgQAuPAxwAJgfwFB4Eo4DQH/AzIcL5hb8AUU/8A6oBIWAMIEKAmH//ACTgHSwJAACgYtgFAn/+AMcAKgBfcLnA1WOM3///ELhq8d4rcd5cE7ltD///0iPFxkoGIBBgarHG4euK5////+JwFxjljJnyAFQMSDsNwvuM4MgFkYbf/////////mwncWeKXGUFkHiaFwF8LTBjyTEAx8DIClBjx3mIoHKAhHc0yBJlLQdGhx9RUFCQ5eGDDBhREMEAkSNpCRlnyQIYDJARpFRhA5hxBlhoZbKh4xgkQkig6CiY0NOjlMKsGZZtEo7GEUkCuBpSvAyB5ZhmkRs2ps1IY7GT5kxhii4lTMoEW+ZMiYkaYkmPLyVeJa0ArXn+M2jKxIBKiJEChLchQEUCTDjyI4FhhIPLbITSIeJAQEvTUeSkjRdRChsDAV3F4Em3kYnflE4HqEJsJxYlVAIPERQZkNiARDBEZADDwsEphZdItKcIHNgoyAWbkqazjJzO+4HUB3xn/+pLATywXg9VkwS4N50mCwRflwd3pMcECSzPjMpk51kgQ4A2MyAM6EgAudpBxMjCgEgRkcTVAYZMSVFCZztxikBlwZlz5gjANNAIUCgw6FNghLLGDAGjTGDOjYkLAlYUrS1hEAdRMl9QMaRdBAVMFc4NIGXFOeyV+X5QoGg4EDu23yFS5Ejy+8Ntaa24qdMrnYd4YlhODgmT/MYgEMy2mO8oOEmFMTQzMOBqMbDEAy6aEzGmFBjqCOkRlA4JQoynl5DHzIyZfMERAIIAQhBQKIhUIPQ4xBwErQIRYxsYM3gDMQA5ZsN+cDACkyo8250MHiIINBzHiwIPBhc9KUADy5RkQachcdE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { h, render, CustomComponent } from 'yolk'; | |
const createCustomComponent = CustomComponent.extend; | |
const Custom = createCustomComponent({ | |
onMount (props, node) { | |
this._instance = { | |
update: (props) => { | |
this._instance.currentProps = props; | |
console.log(this._instance.currentProps); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const zip = (arr, length = 2) => | |
Array.from({ length }, (_, i) => | |
arr.filter((_, j) => | |
j % length === i)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http'); | |
const methods = [ 'get', 'put', 'post', 'delete', 'head' ]; | |
const isStream = obj => | |
obj && | |
typeof obj === 'object' && | |
typeof obj.pipe === 'function'; | |
const isReadable = obj => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const memoize = (fn) => { | |
const cache = new Map(); | |
const memo = (...a) => { | |
const key = a.reduce((hash, val) => | |
hash += val === Object(val) ? | |
JSON.stringify(val) : | |
val, ''); | |
if (!cache.has(key)) cache.set(key, fn(...a)); | |
return cache.get(key); | |
} |
OlderNewer