Skip to content

Instantly share code, notes, and snippets.

View nblackburn's full-sized avatar

Nathaniel Blackburn nblackburn

View GitHub Profile
input::-webkit-input-placeholder {
color: #666666;
}
input :-moz-placeholder {
color: #666666;
}
input::-moz-placeholder {
color: #666666;

devRant Slack Theme

Preview

Preview

Installation

  • Go to the Preferences screen.
  • Click Sidebar theme.
@nblackburn
nblackburn / wildcard-match.js
Last active October 21, 2017 20:07
Check if a string matches a wildcard pattern.
module.exports = (test, pattern) => {
return new RegExp(test.replace(/\*/g, '([^*]+)'), 'g').test(pattern);
};
module.exports = (node, callback) => {
if (node.childNodes) {
for (let index = 0; index < node.childNodes.length; index++) {
const child = node.childNodes[index]
const next = callback(child)
if (!next) {
walk(child, callback)
}
}
@nblackburn
nblackburn / blockstack.md
Created March 23, 2018 23:24
Blockstack
@nblackburn
nblackburn / consecutive-search.js
Created August 3, 2018 13:27
Consecutive search
module.exports = (query, result, insensitive) => {
let index = 0;
let last = 0;
let matched = false;
// Normalize the strings we are comparing to each other.
if (insensitive) {
query = query.toLowerCase();
result = result.toLowerCase();
}
@nblackburn
nblackburn / randomWeight.js
Last active October 15, 2018 14:41
Select a random item from an array of weights
module.exports = weights => {
let seed = Math.random() * weights.length;
return weights.find(weight => (seed - weight) <= 0);
};
@nblackburn
nblackburn / scheduler.js
Created January 30, 2019 00:02
Scheduler
let events = [];
let timeout = null;
let interval = 100;
const getScheduled = () => {
let now = Date.now();
return events.filter(event => {
return (event.lastInvoked + event.interval) < now;
});
module.exports = (red, green, blue, preferShorthand = false) => {
let colours = [red, green, blue].map(value => value.toString(16));
let canBeCondensed = colours.every(value => value.charAt(0) === value.charAt(1));
if (canBeCondensed && preferShorthand) {
colours = colours.map(v => v.charAt(0));
}
return '#' + colours.join('');
};
module.exports = (foreground, background) => {
const l1 = Math.max(foreground, background);
const l2 = Math.min(foreground, background);
return (l1 + 0.05) / (l2 + 0.05);
};