Skip to content

Instantly share code, notes, and snippets.

View keith's full-sized avatar

Keith Smiley keith

View GitHub Profile
@keith
keith / medium-draft.rb
Last active September 1, 2017 16:01
Create a medium post from a GitHub flavored markdown file
#!/usr/bin/env ruby
#
# Usage: medium-draft TOKEN FILENAME
# Where TOKEN is a medium integration token and FILENAME is the path to the
# markdown file you'd like to post
#
# Get your token from https://medium.com/me/settings (integration tokens section)
#
# This requires httparty and redcarpet
# Install with:
@keith
keith / buffers.vim
Created October 4, 2015 22:13
Get the list of open buffers (for use with fuzzy opening etc)
function! s:BuffersList()
let buffers = range(0, bufnr('$'))
let searchBuffers = []
for buffer in buffers
if buflisted(buffer) && index(searchBuffers, bufname(buffer)) < 0
call add(searchBuffers, bufname(buffer))
endif
endfor
return searchBuffers
endfunction
@keith
keith / v
Created September 30, 2015 02:39
vim profiling helper executable
#!/bin/sh
exec vim --startuptime ~/.cache/vim/"$(date -j -f "%a %b %d %T %Z %Y" "$(date)" "+%s")".log "$@"
@keith
keith / maildir
Created July 25, 2015 16:47
Archive or delete maildir messages
#!/bin/bash
set -e
mail=~/.mail
maildirs=($mail/*)
inbox=INBOX
folders=(new cur)
archive="archive/cur"
trash="trash/cur"
@keith
keith / OverrideExtension.swift
Created June 25, 2015 18:15
Overriding Extensions bug fixed in Swift 2.0
import UIKit
extension UIView {
public override var accessibilityLabel: String? {
get {
return "Hi \(super.accessibilityLabel)"
}
set {
super.accessibilityLabel = newValue
}
@keith
keith / NSEventExtensions.swift
Created February 23, 2015 21:11
A NSEvent extension for changing event charactters
extension NSEvent {
func eventByChangingKeyToKey(key: Int) -> NSEvent? {
var char = unichar(key)
let characterString = NSString(characters: &char, length: 1)
return NSEvent.keyEventWithType(type,
location: locationInWindow,
modifierFlags: modifierFlags,
timestamp: timestamp,
windowNumber: windowNumber,
@keith
keith / Installation.md
Last active August 29, 2015 14:15
Instructions for setting up a Beowulf cluster (use at your own risk)

Installation

  1. Shut down the machine and insert a USB drive with the Ubuntu 10.04 64 bit installation disk.

  2. (Re)Boot the machine and press F12 (on Dell Optiplex 960) during the BIOS loading

  3. Choose USB drive from the list of boot devices.

    • If the machine continues to boot go back to step 2
  4. Once Ubuntu starts up choose 'Install Ubuntu 10.04 LTS' (Desktop LTS ending April 2013)

  5. Choose your timezone and keyboard layout

@keith
keith / gist:cc2307b81ee1270c64f3
Created January 19, 2015 18:59
NSWindow APIs
http://stackoverflow.com/questions/5286274/front-most-window-using-cgwindowlistcopywindowinfo
http://stackoverflow.com/questions/13426488/notification-of-active-document-change-on-os-x
https://github.com/ianyh/Amethyst/blob/master/Amethyst/AMWindowManager.m
http://stackoverflow.com/questions/12540010/how-to-identify-window-under-mouse-with-objective-c
http://stackoverflow.com/questions/15612050/cocoa-objective-c-how-to-know-which-control-is-under-the-cursor
https://github.com/jigish/slate/blob/ff5ee5a53afc05b619cf9eb78e852b83ad714de4/Slate/RunningApplications.m
http://stackoverflow.com/questions/853833/how-can-my-app-detect-a-change-to-another-apps-window
@keith
keith / links.txt
Created November 14, 2014 22:58
Links about iOS and Vim
@keith
keith / search_buffers.vim
Last active August 29, 2015 14:09
Filter buffers through selecta
function! Buffers()
let ids = filter(range(1, bufnr('$')),
\ 'empty(getbufvar(v:val, "&bt"))'
\ . ' && getbufvar(v:val, "&bl")')
let names = []
for id in ids
call add(names, bufname(id))
endfor
return join(names, "\n")