Skip to content

Instantly share code, notes, and snippets.

View bennetthardwick's full-sized avatar

Bennett Hardwick bennetthardwick

View GitHub Profile
@bennetthardwick
bennetthardwick / hugo-resolve-markdown.html
Created January 19, 2021 13:29
Resolve markdown links in hugo without having to use shortcodes. https://bennetthardwick.com/wiki/hugo/resolve-markdown-links/
{{/* The destination of the link. Bind to a variable for convenience. */}}
{{ $path := .Destination }}
{{/* If the link isn't a relative link or is an outbound link,
don't rewrite /*}}
{{ if or (hasPrefix $path "./") (not (hasPrefix $path "http")) (hasPrefix $path "../") }}
{{ $file := .Page.File.LogicalName }}
{{/* If the link has a hash, extract it */}}
@bennetthardwick
bennetthardwick / average.tsv
Last active May 21, 2019 13:35
Dev.to post frequency graph. Thanks: https://gist.github.com/tjdecke/5558084/
day hour value
1 1 59
1 2 62
1 3 55
1 4 48
1 5 30
1 6 75
1 7 50
1 8 39
1 9 37
@bennetthardwick
bennetthardwick / copy-table-to-clipboard.js
Created October 20, 2018 01:11
Turn a table into a JSON and copy it!
(() => {
const table = document.querySelector('table');
const head = document.querySelector('thead');
const body = document.querySelector('tbody');
const keys = Array.from(head.querySelectorAll('th'))
.map(cell => cell.innerText);
const values = Array.from(body.querySelectorAll('tr'))
.map(row => Array.from(row.querySelectorAll('td')).map(cell => cell.innerText));
@bennetthardwick
bennetthardwick / better-anki-cards.css
Last active June 23, 2018 15:18
Better looking alternative to the default Anki cards! Shamelessly inspired by Duolingo TinyCards.
html, body {
background: #E9E9E9;
padding-top: 80px;
}
.card {
margin-top: 40px;
font-family: arial;
font-size: 42px;
text-align: center;
@bennetthardwick
bennetthardwick / quicksort.js
Created April 25, 2018 07:51
An awesome version of Haskell's quick-sort, done in JavaScript.
const quicksort = (arr) => {
return (arr.length <= 0) ? [] : (() => {
let h = arr.shift();
return quicksort(arr.filter(a => h >= a)).concat([h]).concat(quicksort(arr.filter(a => h < a)));
})();
}
{ "dictionary":
[
{ "type": "_activity", "word": "cleaning desks" },
{ "type": "_activity", "word": "opening the fridge several times slowly"},
{ "type": "_activity", "word": "spending too much time on the internet"},
{ "type": "_activity", "word": "typing really fast"},
{ "type": "_activity", "word": "using i3 window manager"},
{ "type": "_activity", "word": "awkwardly presenting to a crowd"},
{ "type": "_activity", "word": "forgetting your Twitter handle"},
{ "type": "_activity", "word": "blowing bubbles"},
@bennetthardwick
bennetthardwick / cirlce_of_trust_resume_grammar.json
Last active April 3, 2018 05:47
Grammar for my /r/circleoftrust resume!
{"nodes":[{"title":"/u/bennettbackward","id":0,"x":-259.06407928466797,"y":81.07447624206543},{"title":"_start","id":1,"x":-454.06427001953125,"y":262.27650451660156},{"id":2,"title":"_end","x":937,"y":214},{"id":3,"title":"is","x":82.43416595458984,"y":-175.14227676391602},{"id":4,"title":"great","x":296.6742858886719,"y":-69.61890029907227},{"id":5,"title":"at","x":469.9915771484375,"y":-73.20529174804688},{"id":6,"title":"_activity","x":746.3172607421875,"y":-53.06079864501953},{"id":7,"title":"often","x":62.381103515625,"y":175.1204071044922},{"id":8,"title":"helps","x":317,"y":313},{"id":9,"title":"_people","x":495,"y":372},{"id":10,"title":"_verb","x":643,"y":422},{"id":11,"title":"_singular_noun","x":716.7571411132812,"y":226.2670135498047},{"id":13,"title":"a","x":293.68788146972656,"y":53.17207908630371},{"id":14,"title":"great","x":466.3510437011719,"y":141.70302963256836},{"id":15,"title":"_adjective","x":428.6051940917969,"y":271.4340362548828},{"id":16,"title":"guy","x":723.8994140625,"y":70.4774
@bennetthardwick
bennetthardwick / cisco-router-cheatsheet.md
Last active March 5, 2018 03:16
A cheatsheet of commands for Cisco Routers. Tag: CAB440

Cisco Router Command Cheatsheet

Getting Started!

After making a phsyical connection to the Router, connect to it through a serial connection. Once connected, press ENTER:

-- System Configuration Dialog --
Press RETURN to get started!
Router>

You are currently in User EXEC mode.

eable privileged EXEC mode

@bennetthardwick
bennetthardwick / useful-archlinux-commands.md
Last active March 1, 2018 04:40
Stuff I need to remember to keep Arch Linux usable.

Useful Arch Linux Commands

Connecting to a projector

  1. View connected video outputs
    > xrandr
      eDP1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 310mm x 170mm
         1920x1080       60.05*   59.93 40.03
    

1680x1050 59.98

@bennetthardwick
bennetthardwick / app-name-generator-graph.json
Last active February 28, 2018 05:54
The graph that determines the grammar of the generated app ideas for my app-name-generator-app. Try uploading this to this directed graph creator: https://bl.ocks.org/cjrd/6863459.
{"nodes":[{"id":6,"title":"try","x":30.077117919921875,"y":393.31903076171875},{"id":8,"title":"and","x":203,"y":313},{"id":9,"title":"_build","x":353,"y":458},{"id":10,"title":"_app","x":421,"y":232},{"id":11,"title":"for","x":561,"y":149},{"id":13,"title":"an","x":485,"y":502},{"id":14,"title":"app","x":660,"y":550},{"id":15,"title":"that's","x":594,"y":456},{"id":16,"title":"that","x":738,"y":441},{"id":17,"title":"like","x":507,"y":339},{"id":18,"title":"but","x":388,"y":94},{"id":19,"title":"helps","x":829,"y":334},{"id":20,"title":"_people","x":996.9619140625,"y":430.50286865234375},{"id":21,"title":"_verb","x":1031.0127563476562,"y":242.44793701171875},{"id":22,"title":"_noun","x":886.2924194335938,"y":106.3885726928711},{"id":24,"title":"_end","x":1126,"y":83},{"id":25,"title":"_start","x":58.66435623168945,"y":573.4929809570312},{"id":28,"title":"_activity","x":829.52197265625,"y":-34.26095962524414},{"id":29,"title":"_app_type","x":642.7021484375,"y":322.42578125}],"edges":[{"source":6,"target":8},{