Skip to content

Instantly share code, notes, and snippets.

💡
Prototyping ideas

Nathaniel Blackburn nblackburn

💡
Prototyping ideas
View GitHub Profile
View README.md

devRant Slack Theme

Preview

Preview

Installation

  • Go to the Preferences screen.
  • Click Sidebar theme.
@nblackburn
nblackburn / wildcard-match.js
Last active Oct 21, 2017
Check if a string matches a wildcard pattern.
View wildcard-match.js
module.exports = (test, pattern) => {
return new RegExp(test.replace(/\*/g, '([^*]+)'), 'g').test(pattern);
};
@nblackburn
nblackburn / camelToKebab.js
Last active Jun 30, 2020
Convert a string from camel case to kebab case.
View camelToKebab.js
module.exports = (string) => {
return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
};
View placeholder.css
input::-webkit-input-placeholder {
color: #666666;
}
input :-moz-placeholder {
color: #666666;
}
input::-moz-placeholder {
color: #666666;
View scrollbar.css
::-webkit-scrollbar {
width: 6px;
}
::-webkit-scrollbar-track {
background-color: #ffffff;
}
::-webkit-scrollbar-thumb {
background-color: #cccccc;
View walkDom.js
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)
}
}
View blockstack.md
View consecutive-search.js
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 Oct 15, 2018
Select a random item from an array of weights
View randomWeight.js
module.exports = weights => {
let seed = Math.random() * weights.length;
return weights.find(weight => (seed - weight) <= 0);
};
View scheduler.js
let events = [];
let timeout = null;
let interval = 100;
const getScheduled = () => {
let now = Date.now();
return events.filter(event => {
return (event.lastInvoked + event.interval) < now;
});
You can’t perform that action at this time.