Skip to content

Instantly share code, notes, and snippets.

Miguel Fonseca mcsf

Block or report user

Report or block mcsf

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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
@mcsf
mcsf / .ctags
Created Jul 4, 2019
ctags definitions for ES6 JavaScript
View .ctags
--langdef=js
--langmap=js:.js
--regex-js=/(export )?function\*?[ \t]+([A-Za-z0-9_$]+)[ \t]*\([^)]*\)/\2/,function/
--regex-js=/(,|(;|^)[ \t]*(var|let|const|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*\{/\5/,object/
--regex-js=/(,|(;|^)[ \t]*(var|let|const|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*function\*?[ \t]*\(/\5/,function/
--regex-js=/(,|(;|^)[ \t]*(var|let|const|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*\[/\5/,array/
--regex-js=/(,|(;|^)[ \t]*(var|let|const|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*[^"]'[^']*/\5/,string/
--regex-js=/(,|(;|^)[ \t]*(var|let|const|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*(true|false)/\5/,boolean/
--regex-js=/(,|(;|^)[ \t]*(var|let|const|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*[0-9]+/\5/,number/
--regex-js=/(,|(;|^)[ \t]*(var|let|const|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*.+([,;=]|$)/\5/,variab
View any2aac
#!/bin/bash
INPUT="$1"
OUTPUT=$(perl -C -Mutf8 -pe 's/\.mp4$/.converted.mp4/i' <<< "$INPUT")
YELLOW=$(tput setaf 3)
BLUE=$(tput setaf 4)
RESET=$(tput sgr0)
View extract-js-examples.sh
#!/bin/bash
# Given an input documentation file, output all JavaScript code snippets
# contained therein.
INPUT_DOC="$1"
OPENING_LINES=$( sed -n '/^```js$/=' "$INPUT_DOC" )
for LINE in $OPENING_LINES; do
View work.sh
#!/bin/bash
for app in \
Docker \
Slack \
Firefox\ Developer\ Edition
Your\ Other\ Work\ Applications
do
echo -n "Launch $app? [Yn] "
read answer
@mcsf
mcsf / posts-blocks-endpoint.php
Created Sep 1, 2018
(For testing purposes) WP API endpoint for parsing a post for blocks.
View posts-blocks-endpoint.php
<?php
/**
* Plugin Name: Blocks endpoint for Posts
* Description: —
*/
add_action( 'rest_api_init', 'mcsf_register_post_blocks_endpoint' );
function mcsf_register_post_blocks_endpoint() {
register_rest_route(
'wp/v2', '/posts/(?P<id>[\d]+)/blocks', array(
View extract-js-examples.sh
#!/bin/bash
# Given an input documentation file, output all JavaScript code snippets
# contained therein.
INPUT_DOC="$1"
OPENING_LINES=$( sed -n '/^```js$/=' "$INPUT_DOC" )
for LINE in $OPENING_LINES; do
View hybrid-blocks.php.diff
diff --git a/lib/blocks.php b/lib/blocks.php
index e28971bad..a2c1d0a89 100644
--- a/lib/blocks.php
+++ b/lib/blocks.php
@@ -177,14 +177,18 @@ function do_blocks( $content ) {
}
}
- // Replace dynamic block with server-rendered output.
- $rendered_content .= $block_type->render( $attributes );
@mcsf
mcsf / roman-numerals.py
Created Mar 24, 2018
Detect and wrap roman numerals with a special "small-caps" span tag
View roman-numerals.py
#!/usr/bin/env python
import sys
import re
re_full = r'(MMM|MM|M)?(CM|CD|DCCC|DCC|DC|D|CCC|CC|C)?(XC|XL|LXXX|LXX|LX|L|XXX|XX|X)?(IX|IV|VIII|VII|VI|V|III|II|I)?'
re_appr = r'\b[MDCLXVI]+\b'
def wrap_roman(matchobj):
s = matchobj.group(0)
You can’t perform that action at this time.