This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Accept Git revision as first argument, otherwise default to HEAD | |
if ! COMMIT=$(git rev-parse "${1-HEAD}"); then | |
exit 255 # Abort bisection | |
fi | |
if ! gh --version >/dev/null 2>&1; then | |
echo "error: 'gh' must be installed'" | |
exit 255 # Abort bisection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Alternative implementation with JQ instead of AWK | |
find packages -depth 2 -name 'package.json' -print0 \ | |
| xargs -0 jq -r ' | |
.dependencies // {} | |
| keys[] | |
| select(contains("@wordpress/")) | |
| sub("@wordpress/"; "") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const htm = require('htm') | |
const h = (type, props, ...children) => ({type, props, children}) | |
const html = htm.bind(h) | |
const API = { | |
"wp.rich": "wp.blockEditor.RichText", | |
"wp.plain": "wp.blockEditor.PlainText", | |
} | |
const toComponent = type => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Map a function over an array, but only return a new array object if the | |
* application of the function to some value isn't identical to the value. | |
* | |
* @example | |
* xs !== xs.map(x => x) | |
* xs === lazyMap(xs, x => x) | |
* | |
* @param {Array} xs Array to be mapped over. | |
* @param {Function} f Function to map over array. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env awk -f | |
{ | |
delete counts | |
for (i = 1; i <= NF; i++) counts[$i]++ | |
if (! min || counts[0] < min) { | |
min = counts[0] | |
result = counts[1] * counts[2] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -l | |
use strict; | |
use warnings; | |
# Solution to https://adventofcode.com/2020/day/5 | |
my @seats = (); | |
# Collect seat IDs by parsing binary sequences | |
while (<>) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
; SOLUTION TO CHALLENGE #20 OF ADVENT OF CODE'S 2020 EDITION | |
; | |
; https://adventofcode.com/2020/day/20 | |
(define (main (filename "sample")) | |
(define tiles (read-tiles filename)) | |
(define part-1 (apply * (corner-tiles tiles))) | |
(define part-2 (sea-roughness (tiles->string tiles))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# search term> i | |
# (partial-name-match) image | |
# (partial-name-match) instagram | |
# (partial-keyword-match) gallery | |
# search term> ig | |
# (exact-keyword-match) instagram | |
# search term> im | |
# (partial-name-match) image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Invoke with | |
# | |
# awk -f script.awk -v term=li blocktypes.tsv | |
# | |
# With blocktypes.tsv: | |
# | |
# list List ul,ol | |
# revue Revue list | |
# paragraph Paragraph text | |
# image Image image,picture |
NewerOlder