Skip to content

Instantly share code, notes, and snippets.

View larryv's full-sized avatar

Lawrence Velázquez larryv

View GitHub Profile
#!/usr/bin/env python3
import itertools
import subprocess
def main():
fmt_pieces = ('', '.', '{:01d}', '{:01d}.', '{:02d}', '{:02d}.')
@larryv
larryv / Utilities.applescript
Last active August 29, 2015 14:12
simple fold implementation
on foldLeft given operator:op, initial:z, sequence:xs
(*
AppleScript handlers can't call handlers that are passed
as parameters because the enclosing script object
doesn't recognize the parameter name as a handler. Work
around this by doing the computation inside an embedded
script object. (See Neuberg, p. 150.)
*)
repeat until xs = {}
set z to op's f(z, item 1 of xs)
@larryv
larryv / gist:4c7905228050a46f66d4
Created December 30, 2014 23:20
generate list of p5-* ports with version and incremented revision
port -q info --index --line --version --revision --name 'p5-*' | awk '
BEGIN {
blacklist["p5-app-ack"] = ""
blacklist["p5-catalyst-plugin-unicode-encoding"] = ""
blacklist["p5-class-mop"] = ""
blacklist["p5-email-mime-modifier"] = ""
blacklist["p5-graveyard"] = ""
blacklist["p5-test-tester"] = ""
blacklist["p5-test-use-ok"] = ""
}
@larryv
larryv / generate_include_rules.sh
Last active January 31, 2016 00:57
converting Unix paths into rsync include patterns
# Read a stream of newline-terminated paths from standard input and
# write the corresponding rsync include patterns to standard output.
#
# In the input, directory paths -- and ONLY directory paths -- must end
# with a slash. All paths are treated as literal strings.
#
# The pattern generation assumes that directories' contents are to be
# copied recursively. It also assumes that "rsync --recursive
# --delete-excluded" will use a final "*" pattern to exclude all
# non-included files. Thus, all ancestors require include patterns too,
@larryv
larryv / die.c
Last active May 2, 2016 00:16
log message and exit
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
void die(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
/* This buffer length is arbitrary. */
@larryv
larryv / yubikey-colemak.sh
Created June 11, 2016 16:15
modifying a YubiKey scanmap to work when OS X is configured for Colemak
#!/bin/sh
ykpersonalize -S 06050a0e08170b0f1c11180d16090c1986858a8e88978b8f9c91988d96898c99271e1f202122232425262b9e28
@larryv
larryv / keybase.md
Last active January 16, 2023 03:53
Keybase proof of identity

Keybase proof

I hereby claim:

  • I am larryv on github.
  • I am larryv (https://keybase.io/larryv) on keybase.
  • I have a public key ASA2PbEQSvMzBp7j89WM-YZemJrpkz0EfZj87XVnLNxNVQo

To claim this, I am signing this object:

@larryv
larryv / perl5-convert-version.tcl
Last active August 10, 2016 23:32
Iterations on a subroutine for changing 0.000-style Perl module versions into 0.0.0-style versions
proc perl5_convert_version {vers} {
if {[string index $vers 0] eq "v"} {
set start 1
} else {
set start 0
}
set index [string first . $vers]
set other_dot [string first . [string range $vers [expr {$index + 1}] end]]
if {$index == -1 || $other_dot != -1} {
return [string range $vers $start end]
@larryv
larryv / parseopt.bash
Last active August 23, 2016 20:03
A small function that uses enhanced getopt(1) to define parameters
parseopt() {
[[ -n $1 ]] || return 1
# Use "--options +" to prevent arguments from being rearranged.
local -r opts=$(getopt --name "$0" --options + --longoptions "$1" -- "${@:2}")
case $((10#$?)) in
1)
# getopt(1) will print an error first.
echo >&2 "Try \`$0 --help' for more information."
return 2
@larryv
larryv / 5BA2C2290B24085829524942AB30D6641F9AF0E3.pub.asc
Created April 6, 2018 04:51
old OpenPGP key (created 2016-06-02, expires 2018-07-13)
-----BEGIN PGP PUBLIC KEY BLOCK-----
mJMEV0+CqxMFK4EEACMEIwQAPhnLUWIaQZlMynz9JvYmUrcC8EJ/r9TK7RuKvGB9
MZAKGdEFEk6rVWRHZ26G679kxkor5iRon7RUq4D3C9JnjagAdLGO/bZurLR5nD8Z
A8Pl7BkzHT3igyxE/U5CMD1T5LJCmvNYWp6n56wB7PK0rbtVSxsh3tmnpHyfTlQR
zv+lvmu0Ikxhd3JlbmNlIFZlbMOhenF1ZXogPHZxQGxhcnJ5di5tZT6I5QQTEwoA
SgIbAQwLCQ0KCAwHCwMEAgEHFQoJCAsDAgUWAAMCAQIeAQIXgAIZARYhBFuiwikL
JAhYKVJJQqsw1mQfmvDjBQJZcDuoBQkD+LH9AAoJEKsw1mQfmvDj6CgCCQFHJ9JV
GfDsafIjIL/lESBEDCyt5Us7yqfRJAYC+aPXPN/ySySmAs/lIB5OpXEguDzk5ZJ8
6mWcuoD03XL1KWX9lwIGJuNlC/eYx+2g2cmHBg5v5husWKHClhAPSLxqOYXu7jEU