Skip to content

Instantly share code, notes, and snippets.

@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 / 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}"` : "";
/*
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));
}
@reeddunkle
reeddunkle / tf2_host_local_server.txt
Created February 18, 2019 01:48
TF2 console commands to allow players to join your game
tf_mm_servermode 0 //Matchmaking |0 = not active|1 = Put in matchmaking pool
tf_mm_strict 2 //0 = Show in browser, and allow ad-hoc|1 = Hide from browser and only allow joins through matchmaking|2 = Hide from browser, but allow ad-hoc joins
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
@reeddunkle
reeddunkle / streamlink_example.md
Last active August 24, 2018 14:29
Example of how to use streamlink to download a VOD
@reeddunkle
reeddunkle / onchange.sh
Created July 10, 2018 03:22 — forked from senko/onchange.sh
Watch current directory and execute a command if anything in it changes
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <[email protected]>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of