Skip to content

Instantly share code, notes, and snippets.

View matthewpersico's full-sized avatar

Matthew O. Persico matthewpersico

  • Greater New York City Area
  • 18:29 (UTC -05:00)
View GitHub Profile
#!/usr/bin/env perl
use strict;
use warnings;
sub mess_with_dollar_under {
print("dollar under is @{[defined($_) ? $_ : q(undef)]} in @{[(caller(0))[3]]}, before the loop\n");
for ( qw ( alpha beta gamma ) ) {
print("dollar under is @{[defined($_) ? $_ : q(undef)]} in @{[(caller(0))[3]]}, in the loop\n");
}
@matthewpersico
matthewpersico / check-and-chdir.pl
Last active April 24, 2021 17:54
'eval' as a control structure
sub some_func {
my $ctx = $_[0];
return undef if ( !$ctx->{wrkdir} or !-d ctx->{wrkdir} );
my $prevdir = getcwd();
chdir $ctx->{wrkdir};
my $status;
$status = f1($c);
@matthewpersico
matthewpersico / post.html
Last active September 23, 2020 15:13
Snippets for Testing code blocks in Blogger
<p><span style="font-family: inherit;">So after I posted my tribute to my deceased dad here on Blogger, I wondered if I could use Blogger to post code. After a number of false starts, I have chosen the easiest way for me to do so. Here's a step by step for you.</span></p><p></p><ul style="text-align: left;"><li><span style="font-family: inherit;">Type out your text. Insert markers where your code should go. Markers should be a separate paragraph with easily findable text, like:<br /><br />[SNIPPET #1 GOES HERE]</span></li><li>Create a new gist for each post. Create a new file in the gist for each snippet.</li><li>Copy the embed link from the gist.</li><li>Switch to "HTML view" in Blogger.<br /></li><li>Locate each snippet marker and remove just the tags around it. I usually start at the marker and work left until I find an end tag. Then I know that the tag to the right of the end tag is the start of my snippet. The tags may be spans and font settings.</li><li>Once you have removed all the tags, replace the sn
@matthewpersico
matthewpersico / sh-script-imode.el
Created April 6, 2020 23:19
Adding colon as a valid function character
;;; sh-script-imode.el --- imenu does not recognize some legal bash constructs.
;;; Commentary:
;;; Dashes in function names. 2016-02-23
;;; Colons in function names. 2020-04-06
;;; Code:
;;; First, make sure to load shell mode.
(require 'sh-script)
@matthewpersico
matthewpersico / cor.md
Last active October 16, 2019 13:17 — forked from Ovid/cor.md
Cor—A minimal object system for the Perl core

NAME

Cor — A minimal OO proposal for the Perl core

VERSION

This is version 0.10 of this document.

AUTHOR

@matthewpersico
matthewpersico / .perldb
Last active March 17, 2021 02:46
A .perldb perl debugger init file.
=head1 NAME
.perldb - Customize your Perl debugger
=head1 USAGE
Save this file in your home directory as C<.perldb>. When you run the Perl
debugger on some code (C<< perl -d some_code.pl >>), it will read this file
and use it to customize your debugger experience.
@matthewpersico
matthewpersico / gist:eeeb263acd42570ba7abe1912ad5f506
Created July 23, 2018 16:18
shellcheck-disable-error-at-point
(defun shellcheck-disable-error-at-point (&optional pos)
"Insert a shellcheck disable directive at the current error in the code."
(interactive)
(-when-let* ((error (tabulated-list-get-id pos))
(buffer (flycheck-error-buffer error))
(id (flycheck-error-id error))
;;(message (flycheck-error-message error))
)
(when (buffer-live-p buffer)
(if (eq (window-buffer) (get-buffer flycheck-error-list-buffer))
@matthewpersico
matthewpersico / gist:d8ad66aecd01bed825a1513bb3c625e0
Last active March 22, 2018 00:52
Freshen up shellcheck's directive's page
PROPOSED:
Shellcheck directives allow you to control how `shellcheck` works, and take the form of comments in files:
hexToAscii() {
# shellcheck disable=SC2059
printf "\x$1"
}
Supported directives are