Skip to content

Instantly share code, notes, and snippets.

View nybblr's full-sized avatar
🌱
I help developers craft their best work, achieve goals, and never stop growing.

Jonathan Lee Martin nybblr

🌱
I help developers craft their best work, achieve goals, and never stop growing.
View GitHub Profile
@nybblr
nybblr / rails-with-bower.md
Last active November 27, 2023 15:41
Rails with Bower. Without bower-rails.
@nybblr
nybblr / 1-easy.js
Last active July 13, 2022 03:40
3 examples of using Async Generators and Async Iteration in JavaScript!
// Create a Promise that resolves after ms time
var timer = function(ms) {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
};
// Repeatedly generate a number starting
// from 0 after a random amount of time
var source = async function*() {
@nybblr
nybblr / apa-to-mla.md
Last active January 24, 2021 07:01
APA to MLA commas

Convert from APA style commas to MLA

This is for all your writer friends: for the MLA or APA purist, why not introduce a little excitement to their day with a belated April fools prank?

Installation

Download the comma script and chmod +x comma to make it executable.

Usage

@nybblr
nybblr / dijkstra.js
Last active July 29, 2019 21:17
Dijkstra's Algorithm in JavaScript.
var graph = [
'AB6',
'AC3',
'BD6',
'CD5',
'CE9',
'DF8',
'DE3',
'EG8',
'FG2'
@nybblr
nybblr / async-generator.js
Last active January 19, 2019 02:16
Tiny example of async generator functions
let timer = (ms) => new Promise(resolve => setTimeout(resolve, ms));
let producer = async function*() {
let counter = 0;
while (true) {
let delay = Math.random() * 1000;
await timer(delay);
yield counter++;
}
};
@nybblr
nybblr / concat.js
Created August 30, 2018 15:15
Playing around with ES2015 Proxy to make an array from two others — without copying! i.e. Array Trie.
const intRegex = /^(0|[1-9]\d*)$/;
let isIndex = prop =>
typeof prop === 'string'
&& intRegex.test(prop);
let concat = (left, right) => {
let w = left.length;
let h = right.length;
#!/usr/bin/env bash
# ~/.macos — https://mths.be/macos
# Close any open System Preferences panes, to prevent them from overriding
# settings we’re about to change
osascript -e 'tell application "System Preferences" to quit'
# Ask for the administrator password upfront
sudo -v
@nybblr
nybblr / example.js
Last active April 5, 2018 15:34
In-browser image resizing + processing
import processImage from 'process-image';
var file = /* File() object from drag-n-drop or file input */
var imageProcessOpts = {
maxWidth: 1200,
maxHeight: 1200,
quality: 0.6
};
@nybblr
nybblr / google-sheets.js
Created January 22, 2018 22:43
Google sheets functions for meetup
function getCost(cell) {
return cell.match(/\$[\d.,]+\d/)[0]
}
function getCondition(cell) {
return cell.match(/((like )?new|used|mint|good|great|excellent)/i)[0]
}
function getEmail(cell) {
return (cell.match(/[^\s@]+@[^\s@]+/i) || ['N/A'])[0]
@nybblr
nybblr / slacks-or-shorts.js
Created January 16, 2018 16:02
Should you wear slacks, or should you wear shorts? This Slackbot will help you decide.
const SlackBot = require('slackbots');
const BOT_NAME = 'Slacks or Shorts';
const BOT_TOKEN = '<YOUR-TOKEN-HERE>';
const BOT_HANDLE = 'slacks-or-shorts';
let bot = new SlackBot({
token: BOT_TOKEN,
name: BOT_NAME
});