Skip to content

Instantly share code, notes, and snippets.

View heptal's full-sized avatar

Michael B heptal

View GitHub Profile
@heptal
heptal / NSInputStreamHelper.swift
Last active October 20, 2015 12:57
Some convenient Swift extension methods for reading raw or binary data in NSInputStream
// 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 = self.read(&readBuffer, maxLength: readBuffer.count)
assert(numberOfBytesRead == len)
return readBuffer
}
@heptal
heptal / terminal_gif.md
Last active December 20, 2015 03:58
GIFs? In MY terminal?!

Video

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.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
heptal / hs_autocomplete.md
Last active January 26, 2016 20:39
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
heptal / docker.md
Last active March 9, 2016 21:36
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
heptal / SASmilieSearch.user.js
Last active May 2, 2016 16:04
Smilie autocomplete search box
// ==UserScript==
// @name SASmilieSearch
// @namespace forums.somethingawful.com
// @version 0.1.5
// @description Smilie autocomplete search box
// @author Me
// @match http://forums.somethingawful.com/misc.php?action=showsmilies
// @match https://forums.somethingawful.com/misc.php?action=showsmilies
// @grant none
// ==/UserScript==
// ==UserScript==
// @name SAThreadSearch
// @namespace forums.somethingawful.com
// @version 0.2
// @description Inline thread search
// @author Me
// @match http://forums.somethingawful.com/showthread.php*
// @match https://forums.somethingawful.com/showthread.php*
// @grant none
// ==/UserScript==
@heptal
heptal / volumes.md
Last active July 18, 2016 10:02
Removable volume manager in Hammerspoon

A simple menubar utility for opening/ejecting/managing removable volumes that looks good in OSX Dark mode:

Conveniently hides itself when no volumes are mounted and reappears when one is mounted:

Get it here - volumes.lua

Save as volumes.lua in ~/.hammerspoon/ and put volumes = require "volumes" in your init.lua