Skip to content

Instantly share code, notes, and snippets.

View larryv's full-sized avatar

Lawrence Velázquez larryv

View GitHub Profile
@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 / 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 / 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)
#!/usr/bin/env python3
import itertools
import subprocess
def main():
fmt_pieces = ('', '.', '{:01d}', '{:01d}.', '{:02d}', '{:02d}.')
# Save port to hold space.
/ has the variants/ {
s/ has .*$//
h
d
}
# Remove noise.
/conflicts with/d
/^[^:]*mariadb[^:]*:/b db_variant
@larryv
larryv / gist:6ac42cb9e9599d14ac6d
Created September 8, 2014 19:45
C++ is terrible
[20:36:38] <larryv> geekosaur: oy, all this is giving me a headache
[20:38:13] <geekosaur> yes
[20:45:29] <geekosaur> hopefully my latest reply clarifies the actual issue
[20:50:03] <geekosaur> (implied but not stated, btw: C++11 broke *everyone's* existing C++ runtime API/ABI)
[20:53:41] <larryv> haha
[20:53:58] <larryv> yes, it's much clearer now, thanks
[20:54:45] <geekosaur> also it is bnoth API and ABI because they need bit level compatibility for objects compiled with one C++ compiler to work with objects compiled by a different one; API alone is insufficient
[20:58:12] <larryv> is that mitigated if both standard libraries use the same low level support?
[20:58:30] <larryv> i.e., libstdc++ on OS X using libc++abi
[20:58:35] <larryv> or libc++ on Linux using libsupc++
#!/usr/bin/env zsh
emulate -R zsh # Reset (most) options to defaults.
setopt EXTENDED_GLOB
##### APPETIZERS (or: preliminary setup) #####
#
# Adapted from git's "git-sh-setup".
def sortCodeTrees[T <: CodeTree](trees: List[T]): List[T] = {
val pivot = trees.length / 2
if (pivot == 0) trees
else {
def merge(xs: List[T], ys: List[T]): List[T] = (xs, ys) match {
case (Nil, ys) => ys
case (xs, Nil) => xs
case (x :: xs1, y :: ys1) =>
if (weight(x) < weight(y)) x :: merge(xs1, ys)
else y :: merge(xs, ys1)
def times(chars: List[Char]): List[(Char, Int)] = {
def incr(pairs: List[(Char, Int)], C: Char): List[(Char, Int)] =
pairs match {
case Nil => List((C, 1))
case (C, n) :: ps => (C, n+1) :: ps
case p :: ps => p :: incr(ps, C)
}
(chars foldLeft List[(Char, Int)]())(incr)
}
@larryv
larryv / py-scipy.patch
Created February 10, 2014 01:31
Enabling a universal MacPorts build of SciPy.
Index: Portfile
===================================================================
--- Portfile (revision 116903)
+++ Portfile (working copy)
@@ -3,6 +3,7 @@
PortSystem 1.0
PortGroup python 1.0
+PortGroup muniversal 1.0