Skip to content

Instantly share code, notes, and snippets.

View d13's full-sized avatar
🚀

Keith Daulton d13

🚀
View GitHub Profile
@d13
d13 / deep-search.js
Last active January 16, 2020 02:29
JS util ideas
function keyFirstSearch(obj, term) {
for (const key of Object.keys(obj)) {
if (key === term) {
return obj[term];
}
const prop = obj[key];
if (typeof prop === 'object') {
const nested = keyFirstSearch(prop, term);
if (nested !== undefined) {
@d13
d13 / app.html
Last active May 30, 2020 10:11
Aurelia Gist - nav in a LayoutView
<template>
<require from="nav-bar.html"></require>
<!-- this nav works -->
<nav-bar router.bind="router"></nav-bar>
<div class="page-host" style="margin-top:50px">
<router-view router.bind="router"></router-view>
</div>
</template>
@d13
d13 / app.html
Created September 1, 2016 20:37 — forked from jdanyow/app.html
Aurelia Gist
<template>
<h1>${message}</h1>
</template>
@d13
d13 / README.md
Created February 25, 2016 03:45 — forked from jedireza/README.md
ajaxStart and ajaxStop for ampersand-model using the ajaxConfig

Also see the discussion about global ajax settings:

Add support for a global ajaxConfig > Thus far we've just gone for having a base model and base collection in every project.

@d13
d13 / mq.less
Last active October 15, 2015 03:43
retina media-query
.m-mq(@query, @ruleset) {
@media @query {
@ruleset();
}
};
.m-mq-retina(@ruleset) {
@query: ~"only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min--moz-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (min-device-pixel-ratio: 1.5), only screen and (min-resolution: 192dpi)";
.m-mq(@query, @ruleset);
};
.icon-foo {
@d13
d13 / buildTmpl.js
Created July 29, 2015 03:25
Quick n' Dirty Mustache Variable Replacement
/**
* Function that replaces mustache variables in a string with values from the data object
* @param {String} tmpl String with the variables to be replaced
* @param {Object} data Object with data to be populated
* @return {String} Returns a string with mustache variables replaced
*/
var buildTmpl = function(tmpl, data) {
if (!data) {
return tmpl;
}
@d13
d13 / notepad-bookmarklet
Last active August 29, 2015 14:14
Notepad bookmarklet I made a while ago with Behave.js
data:text/html, <html><head><style type="text/css"> html { font-family: Arial } </style><script src="http://jakiestfu.github.com/Behave.js/behave.js"></script><script>window.onload=function(){var editor = new Behave({textarea: document.getElementById('myTextarea')});};</script></head><body><textarea id="myTextarea" style="width:100%;height:100%;margin:0 auto;padding:1rem;font-size:1rem; border: none; outline: none" autofocus></textarea></body>
@d13
d13 / XmlPoster.js
Last active April 1, 2016 15:39
Node.js: Simple XML API requests
var request = require('request');
var assign = require('lodash.assign');
var XmlPoster = function(options) {
this.url = options.url;
this.headers = options.headers || {};
};
XmlPoster.prototype.request = function(body) {
var me = this;
var xmlConfig = {
@d13
d13 / 1-source.less
Last active August 29, 2015 14:14
LESS and BEM experiment
#BEM {
.glue(@glue, @selector, @styles) {
&@{glue}@{selector} {
@styles();
}
}
.e(@name, @styles) {
#BEM > .glue(__, @name, @styles);
}
.m(@name, @styles) {
@d13
d13 / gist:94822666b387249647d5
Created December 1, 2014 20:30
Styling console.log
console.log("%c D %c 13 %c DESIGN ", "background: red; color: white; padding: 2px", "background: blue; color: white; padding: 2px", "");