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
heptal / volumes.md
Last active Jul 18, 2016
Removable volume manager in Hammerspoon
View volumes.md

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

@heptal
heptal / hs_autocomplete.md
Last active Jan 26, 2016
hammerspoon autocomplete
View hs_autocomplete.md

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 / amphetamine.md
Last active Dec 29, 2019
Hammerspoon replacement for Caffeine
View amphetamine.md

Amphetamine

Simple toggleable menubar replacement for Caffeine in Hammerspoon, utilizing ASCIImage (for vector) to create the amphetamine icons. Motivated by the official Caffeine app's icon looking bad on Retina

Get latest version here: amphetamine.lua

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

@heptal
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 = self.read(&readBuffer, maxLength: readBuffer.count)
assert(numberOfBytesRead == len)
return readBuffer
}
View ipython.md

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 (

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.
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.
@heptal
heptal / terminal_gif.md
Last active Dec 20, 2015
GIFs? In MY terminal?!
View terminal_gif.md

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.

View console_colors.md

Displaying images in the terminal with tput and echo

output

Requires ImageMagick, easily available from your favorite package manager. Tested on Linux and OSX
convert image.png -resize 40 txt:-|sed -E 's/://;s/\( ? ?//;s/, ? ?/,/g;s/\)//;s/([0-9]+,[0-9]+,[0-9]+),[0-9]+/\1/g;s/255/254/g;/mage/d'|awk '{print $1,$2}'|sed -E 's/^0,[0-9]+ /print "echo;tput setaf "\;/;s/^[0-9]+,[0-9]+ /print "tput setaf ";/;s/(.+),(.+),(.+)/\1\/42.5*36+\2\/42.5*6+\3\/42.5+16/'|bc|sed 's/$/;echo -n "  ";/'|tr '\n' ' '|sed 's/^/tput rev;/;s/; /;/g;s/$/tput sgr0;echo/'|bash
You can’t perform that action at this time.