Skip to content

Instantly share code, notes, and snippets.

Alexis Gallagher algal

Block or report user

Report or block algal

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
algal / RangeStrider.swift
Last active Apr 30, 2019
Sequence of Range<Int>s
View RangeStrider.swift
// known-good: Swift 5.0.1
# how to use:
instead of:
for i in 0 ..< (n-1)/bs {
let startIdx = i * bs
algal / PileView.swift
Last active Mar 8, 2019
Like a simple vertical stack view. No animations. But no magical mystery meat, and it works.
View PileView.swift
// Pile.swift
// PileTest
// Created by Alexis Gallagher on 3/6/19.
// Copyright © 2019 Bespoke. All rights reserved.
// known-good: Swift 4.2, iOS 12
algal / Zipping.swift
Created Feb 17, 2019
Zip files on iOS, without using external libraries and without interoperating with the low-level Compression framework
View Zipping.swift
// Zipping.swift
// known-good: Swift 4.2
// Alexis Gallagher
import Foundation
public extension URL {
/// Creates a zip archive of the file or folder represented by this URL and returns a references to the zipped file
algal / regex.swift
Last active Feb 6, 2019
Swift Regular Expression Helpers
View regex.swift
// known-good: Swift 4.2
// expected good: Swift 5.0
import Foundation
This file defines three helpers for matching regular expressions against strings, and inspecting the results of capture groups in the regular expressions.
1. `RegexMatches(ofPattern:againstString:)` provides a lazy Sequence of matches, where every match is an array representing the matches capture groups.
algal / loadPoints.swift
Created Dec 28, 2018
Read vertex positions with Model I/O
View loadPoints.swift
// known-good: Swift 4.2, macOS
import Foundation
import ModelIO
private func LogDebug(_ s:Any) -> Void { print(s) }
private func LogInfo(_ s:Any) -> Void { print(s) }
private func LogError(_ s:Any) -> Void { print(s) }
struct POINT3D {
var x:Float
algal / readlines.swift
Last active Dec 11, 2018
Read lines in Swift
View readlines.swift
// known good: Swift 4.2
import Foundation
/// Returns an iterator that iterates through the lines of the file at path.
/// - Parameter path: path of the file to read
/// - Returns: the iterator, or nil if the file could not be read
func lineSequence(forFileAtPath path:String) -> AnyIterator<String>?

Obviously the big question is whether it's wise to add these protocols. But I got curious and did a little research just on the naming question, to see if "intensional set" and "extensional set" are well-established mathematical terms for different kinds of sets. Seems like they're not.

I checked two reference works -- The Princeton Companion to Mathematics and the Encyclopedic Dictionary of Mathematics (2nd edition). I looked in their tables of contents, their indexes, and in their articles discussing set theory, and there is no mention of the idea of an "intentional set" or an "extensional set". Also, anecdotally, I did some math in grad school and never ran into the terms.

The terms "extensional" and "intensional" originate in philosophy of l

algal / osxvpnrouting.markdown
Created Oct 4, 2018 — forked from Eradash/osxvpnrouting.markdown
Routing tips for VPNs on OS X
View osxvpnrouting.markdown

Routing tips for VPNs on OS X

When VPNs Just Work™, they're a fantastic way of allowing access to a private network from remote locations. When they don't work it can be an experience in frustration. I've had situations where I can connect to a VPN from my Mac, but various networking situations cause routing conflicts. Here are a couple of cases and how I've been able to get around them.

Specific cases

Case 1: conflicting additional routes.

In this example the VPN we are connecting to has a subnet that does not conflict with our local IP, but has additional routes that conflict in some way with our local network's routing. In my example the remote subnet is 10.0.x.0/24, my local subnet is 10.0.y.0/24, and the conflicting route is Without the later route, I can't access all hosts on the VPN without manually adding the route after connecting to the VPN:

# known-good: python 3.7.0
class RunOutput(object):
def __init__(self, return_code, stdout, stderr):
self.return_code = return_code
self.stdout = stdout
self.stderr = stderr
def run_tee(s):
"""Runs shell command s, returning a RunOutput with (return_code, stdout, stderr).
View kill-buffer-file-name-or-name.el
;; Car salesman, *slapping roof of defun*: this bad boy can fit so much damn file management convenience in it.
(defun kill-buffer-file-name-or-name ()
"Pushes a useful path to the kill ring.
When visiting a file, pushes the file's path. In dired,
pushes the path of the file at point or else the current
directory. In magit, pushes the path of the file at point or else
the repo's root. Otherwise, pushes buffer's name. Displays
whatever was pushed in the message area."
You can’t perform that action at this time.