Skip to content

Instantly share code, notes, and snippets.

Michael B heptal

  • Baton Rouge, LA
Block or report user

Report or block heptal

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
heptal / NSInputStreamHelper.swift
Last active Oct 20, 2015
Some convenient Swift extension methods for reading raw or binary data in NSInputStream
View NSInputStreamHelper.swift
// Convenience extension for reading from NSInputStream from swift
// Useful for reading binary data in chunks using arbitary structs
extension NSInputStream {
func readByteArray(len: Int) -> [UInt8] {
var readBuffer = Array<UInt8>(count:len, repeatedValue: 0)
let numberOfBytesRead =, maxLength: readBuffer.count)
assert(numberOfBytesRead == len)
return readBuffer
heptal /
Last active Dec 20, 2015
GIFs? In MY terminal?!


Seems to run stable for hours!

If you can't see your cursor after killing it, run tput cnorm

Sometimes you may see a seq error if you run it multiple times with different resolutions in the same session. Easier to make a new session, or you can change it unset the variables used initially.

View aphex_twin.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View ASCII Art Server in Julia.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Getting started with IPython Notebook and Anaconda

For beginners and experts alike, IPython Notebook, along with the package collection Anaconda, has to be the premier interactive Python environment for playing, learning, prototyping, and exploring data. IPython Notebook is a browser-based environment where you can combine code execution, text, mathematics, plots and rich media into a single document. Look at these awesome examples (

heptal /
Last active Jan 26, 2016
hammerspoon autocomplete

Hammerspoon console autocomplete

Hackjob of autocomplete in the Hammerspoon console
Binds tab to autocomplete when console window has focus using hs.window.filter
This is all user lua except for the added hs.console.getInput which returns text and cursor position
Autocompletes on everything in _G, help.hs.whatever, hs.thing.otherthing, etc. Autocompletes userdata object methods via getmetatable

local function complete(consoleInput)
    local text, position = consoleInput['text'], consoleInput['cursorPosition']
heptal /
Last active Mar 9, 2016
Docker manager in Hammerspoon

Docker management menubar utility

Got tired of having to constantly manipulate the docker CLI commands for basic operations and for which the API has changed rapidly in the past year (much top-ranked info out there is out of date)

Assuming docker is installed (brew cask install dockertoolbox):

  • Start/stop/remove docker containers
  • Easily copy container IP to pasteboard addresses by just clicking
  • Conveniently open browser on container's exposed port
  • Open Kitematic GUI app included with dockertoolbox by clicking Docker
heptal /
Last active Apr 18, 2016
Poor man's imitation of Postman in Hammerspoon

Exploring the possibilities with hs.webview and hs.webview.usercontent. The primary feature here is WKUserContentController, which allows for injecting user scripts into a web view and for JavaScript to post messages directly back to the native runtime.

The good thing is it's very easy to design the web portion in JS sketchbooks such as jsbin/codepen/jsfiddle because the snippet code structure maps cleanly to this. The bad part is that WKWebView doesn't always behave consistently or have a clean slate. Maybe this will help resolve state issues in the future. It will randomly not be able to find injected scripts without any code changes, and I haven't figured out why.

In this, a two-column table in HTML can be filled with values from Lua tables, and can also send them back. This is used for HTTP requests with arbitrary headers in a fun and exciting way.

heptal /
Last active Apr 20, 2016
Lua pattern matcher UI in Hammerspoon webview

local name = "id""-","");

local html = [[
.   all characters
%a  letters
%b  balanced delimiters
%c  control characters
heptal / SASmilieSearch.user.js
Last active May 2, 2016
Smilie autocomplete search box
View SASmilieSearch.user.js
// ==UserScript==
// @name SASmilieSearch
// @namespace
// @version 0.1.5
// @description Smilie autocomplete search box
// @author Me
// @match
// @match
// @grant none
// ==/UserScript==
You can’t perform that action at this time.