Skip to content

Instantly share code, notes, and snippets.

Avatar

Miguel Fonseca mcsf

View GitHub Profile
View find-block-type.sh
#!/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
View find-block-types.awk
# 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
@mcsf
mcsf / x.sh
Last active Aug 18, 2020
Tasks with `x` and `o` (Bash)
View x.sh
#!/bin/bash
CMD=$(basename "$0")
CONF="$HOME/.x.conf"
# shellcheck disable=1090
[ -f "$CONF" ] && source "$CONF"
X_BASE=${X_BASE:-$HOME/Desktop}
X_LOG=${X_LOG:-$X_BASE/log.txt}
X_ARCHIVE_TEMPLATE=${X_ARCHIVE_TEMPLATE:-+$X_BASE/tasks-%Y-%m-%d.txt}
@mcsf
mcsf / derp-case.js
Created Aug 7, 2020
It's a silly world out there.
View derp-case.js
#!/usr/bin/env node
const fs = require('fs');
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false,
});
View wp-env-test-docker-load.sh
set -e
# Clean
if pgrep -f Docker.app ; then
echo "Please manually quit Docker and try again."
exit 1
fi
# Prep
echo "Starting Docker daemon…"
View ffmpeg2gif
#!/bin/sh
ffmpeg -i "$1" -vf "fps=10,scale=740:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gif
@mcsf
mcsf / my-test.php
Last active Mar 19, 2020
[Per Slack request] Illustrating the use of WordPress data selectors in conjunction with React hooks to react to post saving within a custom sidebar in Gutenberg. Move advanced entity-centric selectors may be used from the 'core' store instead.
View my-test.php
<?php
/*
Plugin Name: Test
*/
function my_test_enqueue_scripts() {
wp_enqueue_style(
'my-test-style',
plugins_url( 'style.css', __FILE__ )
);
@mcsf
mcsf / proj.sh
Created Mar 9, 2020
Given a command such as "docker-compose up", identifies the project root (the nearest ancestor containing e.g. "docker-compose.yml") and runs the command from there
View proj.sh
#!/bin/sh
set -e
callee="$1"
invocation="$@"
target=""
case "$callee" in
docker-compose)
View bisect-script.sh
#!/bin/bash
TEST_SUITE="change-detection"
TEST_NAME="consecutive edits"
E2E_PATCH="bisect-e2e.diff"
skip() {
echo Skipping: $@; exit 125
}
View .vimrc
let mapleader = " "
let maplocalleader = " "
filetype plugin on
" === Begin Plug
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif