Skip to content

Instantly share code, notes, and snippets.

View kconner's full-sized avatar
✍️

Kevin Conner kconner

✍️
View GitHub Profile
@kconner
kconner / gist:3029300
Created July 1, 2012 19:18
Vimlike SublimeText setup

Some parts of this are personal preference, others are specific to Mac OS X.

  • First, install SublimeText.
  • In SublimeText / Preferences / Color Scheme, choose Solarized Dark (or don't).
  • Open the user preference file (SublimeText / Preferences / Settings — User), add a comma after the last preference before the closing brace, and paste all of this after the comma:
    // Don't exclude Vim.
 "ignored_packages": [
@kconner
kconner / gist:3453403
Created August 24, 2012 17:47
Solarized Dark colors for Marked.app Github style
/*
This document has been created with Marked.app <http://markedapp.com>, Copyright 2011 Brett Terpstra
Please leave this notice in place, along with any additional credits below.
---------------------------------------------------------------
Title: GitHub
Author: Brett Terpstra
Description: Github README style. Includes theme for Pygmentized code blocks.
Colors tweaked toward Solarized Dark by Kevin Conner.
*/
@kconner
kconner / gist:5057423
Last active June 19, 2020 18:20
A shell tool for opening GitHub pages
## For bash or zsh:
# Opens the github page, issue, or new pull request for the current git repository in your browser
# Based on https://github.com/jasonneylon/dotfiles/
function gh {
giturl=$(git config --get remote.origin.url)
if [ "$1" = "help" ]; then
echo "gh: Opens this repository's GitHub homepage."
echo "gh 123 246: Opens the page for issues or pull requests #123 and #246."
echo "gh issues: Opens the repository's issues."
@kconner
kconner / monitor.sh
Created October 22, 2014 14:07
Monitor whether a given URL gives you a 200
#!/bin/bash
echo "Monitoring."
while true; do
if curl -s --head $1 | grep "200 OK" > /dev/null; then
echo "ok" $1
else
echo ":(" $1
fi
@kconner
kconner / gist:dfecaa5a26acf4c65f9b
Created November 14, 2014 18:52
Memoization in Swift
class Memo<T> {
private let closure: () -> T;
private var result: T?
var value: T {
if let value = result {
return value
} else {
let value = closure()
println("computed \(value)")
@kconner
kconner / gist:eb1ef62edd0ff991a186
Created November 21, 2014 18:49
Currying, argument reordering, and partial function application in Swift
func curry<T, U, R>(binary: (T, U) -> R) -> T -> U -> R {
return { t in
return { u in
return binary(t, u)
}
}
}
func curry<T, U, V, R>(ternary: (T, U, V) -> R) -> T -> U -> V -> R {
return { t in
@kconner
kconner / GameViewController.swift
Last active February 7, 2017 01:10
Xcode 6.3 OpenGL Game template ported to Swift. (Add "-D DEBUG" to Other Swift Flags setting)
import GLKit
// Uniform index.
private enum Uniform {
case ModelViewProjectionMatrix, NormalMatrix
}
private var gUniforms: [Uniform: GLint] = [:]
extension GLKMatrix3 {
var array: [Float] {
# .khdrc script for https://github.com/koekeishiya/khd
# lcmd + .OEU (Dvorak ESDF) = arrows
lcmd - o : /usr/local/bin/khd -p "- left"
lcmd - e : /usr/local/bin/khd -p "- down"
lcmd - 0x0e : /usr/local/bin/khd -p "- up"
lcmd - u : /usr/local/bin/khd -p "- right"
rcmd + lcmd - o : /usr/local/bin/khd -p "cmd - left"
rcmd + lcmd - e : /usr/local/bin/khd -p "cmd - down"
E017 DO YOU EXPECT ME TO FIGURE THIS OUT?
E079 PROGRAMMER IS INSUFFICIENTLY POLITE
E099 PROGRAMMER IS OVERLY POLITE
E111 COMMUNIST PLOT DETECTED, COMPILER IS SUICIDING
E123 PROGRAM HAS DISAPPEARED INTO THE BLACK LAGOON
E127 SAYING ’ABRACADABRA’ WITHOUT A MAGIC WAND WON’T DO YOU ANY GOOD
E129 PROGRAM HAS GOTTEN LOST
E139 I WASN’T PLANNING TO GO THERE ANYWAY
E182 YOU MUST LIKE THIS LABEL A LOT!
E197 SO! 65535 LABELS AREN’T ENOUGH FOR YOU?
@kconner
kconner / printData.swift
Created May 31, 2017 21:37
Print the bytes of a Data in hexadecimal
private func printData(_ data: Data) {
let hexBytes = data.map { byte in
String(format: "%02x", byte)
}
for (offset, hexByte) in hexBytes.enumerated() {
let terminator: String
switch offset % 8 {
case 7:
terminator = "\n"