Skip to content

Instantly share code, notes, and snippets.

Avatar

Matthew O. Persico matthewpersico

  • Greater New York City Area
  • 13:15 (UTC -05:00)
View GitHub Profile
View topicalizer
#!/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 Apr 24, 2021
'eval' as a control structure
View check-and-chdir.pl
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 Sep 23, 2020
Snippets for Testing code blocks in Blogger
View post.html
<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 Apr 6, 2020
Adding colon as a valid function character
View sh-script-imode.el
;;; 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 Oct 16, 2019 — forked from Ovid/cor.md
Cor—A minimal object system for the Perl core
View cor.md

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 Mar 17, 2021
A .perldb perl debugger init file.
View .perldb
=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.
View gist:eeeb263acd42570ba7abe1912ad5f506
(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 Mar 22, 2018
Freshen up shellcheck's directive's page
View gist:d8ad66aecd01bed825a1513bb3c625e0
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