Skip to content

Instantly share code, notes, and snippets.

- Limit response to 5 lines, excluding code.
- Focus solely on essential information or thought-provoking content.
- Insert prompts to clarify or stimulate thought.
- Ask questions that lead to improved answers.
- Extend code quality beyond the initial query.
- Disclose any uncertainties and offer solutions with trade-offs.
- Break code into modular, composable functions.
- Limit each response to a maximum of 5 points.
@reeddunkle
reeddunkle / volta-lightning.md
Last active January 6, 2023 17:06
Volta lightning
@reeddunkle
reeddunkle / first_github_commit.js
Created October 24, 2020 14:32
Save as bookmark. Open on a GH repo to see first commit.
javascript:(b=>fetch('https://api.github.com/repos/'+b[1]+'/commits?sha='+(b[2]||'')).then(c=>Promise.all([c.headers.get('link'),c.json()])).then(c=>{if(c[0]){var d=c[0].split(',')[1].split(';')[0].slice(2,-1);return fetch(d).then(e=>e.json())}return c[1]}).then(c=>c.pop().html_url).then(c=>window.location=c))(window.location.pathname.match(/\/([^\/]+\/[^\/]+)(?:\/tree\/([^\/]+))?/));
@reeddunkle
reeddunkle / arabicToRomanNumerals.js
Created October 14, 2020 20:26
Arabic to Roman Numeral Values 1-5100
var arabicToRomanNumerals = [
[1, "I"],
[2, "II"],
[3, "III"],
[4, "IV"],
[5, "V"],
[6, "VI"],
[7, "VII"],
[8, "VIII"],
[9, "IX"],
@reeddunkle
reeddunkle / truncateRichText.js
Last active June 4, 2020 15:56
Partial solution to trucate rich text AST
const truncateRichText = (richText, options) => {
let characterCount = 0;
const _truncateRich = (rich) => {
const { children } = rich;
const truncatedChildren = children.reduce((accumulator, node, index) => {
if (characterCount < options.length) {
if (isString(node)) {
const nextCount = characterCount + node.length;
0:58 ──♤───── 3:47
↻ ◁ II ▷ ↺

ılı.lıllılı.ıllı....llı.........lıl..lı.................
ᴠᴏʟᴜᴍᴇ : ▮▮▮▮▮▮▯▯▯
@reeddunkle
reeddunkle / resizeMdImg.md
Last active November 1, 2019 19:57
Convert Markdown image link to HTML `<img>` with resize percent

Convert Markdown image link to HTML <img> with resize percent:

const resizeMdImg = (mdImgStr, size) => {
  if (!mdImgStr) return;

  const mdImgExpression = /^!\[(.*)\]\((.*)\)/;
  const { 1: alt, 2: src } = mdImgStr.match(mdImgExpression);
  const sizeStr = size ? ` height="${size}" width="${size}"` : "";
@reeddunkle
reeddunkle / wipe_and_convert_gpt.md
Last active September 16, 2019 13:00
Windows Startup clean disks and convert to gpt

To manually wipe a drive and convert it to GPT:

  1. Turn off the PC, and put in the Windows installation DVD or USB key.

  2. Boot the PC to the DVD or USB key in UEFI mode. For more info, see Boot to UEFI Mode or Legacy BIOS mode.

  3. From inside Windows Setup, press Shift+F10 to open a command prompt window.

  4. Open the diskpart tool:

    diskpart
    
/*
TODO: Change API to make `paths` an array of strings | object
*/
const pickAs = (obj, paths) => {
return Object.entries(paths).reduce((accumulator, [path, definition]) => {
const resultValue = get(obj, path);
if (definition === true) {
accumulator[path] = resultValue;
} else if (isFunction(definition)) {
@reeddunkle
reeddunkle / foldBy.js
Created July 31, 2019 14:56
Nest a flat array
function foldBy(constructor, arr) {
if (!arr.length) return null;
const [item, ...rest] = arr;
return constructor(item, foldBy(constructor, rest));
}