Skip to content

Instantly share code, notes, and snippets.

View keith's full-sized avatar

Keith Smiley keith

View GitHub Profile
@keith
keith / optimizationCrash.swift
Last active October 14, 2016 20:07
Swift 3.0 optimizations crash (fixed in Xcode 8.1 beta 3)
///
/// This code crashes with Swift 3.0 with optimizations enabled
/// Run with:
/// $ swift -O optimizationCrash.swift
///
extension Dictionary {
// init(pairs: [(Key, Value)]?) { // With `(Key, Value)` this doesn't crash
init(pairs: [Element]?) { // With `Element` this crashes with -0
self.init()
}
@keith
keith / link.sh
Last active December 22, 2016 13:35
Build to iOS 10 from Xcode 7.3.1

Keybase proof

I hereby claim:

  • I am keith on github.
  • I am smileykeith (https://keybase.io/smileykeith) on keybase.
  • I have a public key whose fingerprint is AC20 B263 327E 9C9A A61A 55A1 33BA 60D4 4C71 67F8

To claim this, I am signing this object:

@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