Skip to content

Instantly share code, notes, and snippets.

View ghthor's full-sized avatar
🦆
Ducking

Will Owens ghthor

🦆
Ducking
View GitHub Profile
@ghthor
ghthor / Deserialize.swift
Last active August 27, 2016 17:50
An example of using flatMap to extract fields from a [String: AnyObject] dictionary into a concrete type
import Foundation
func toString(obj: AnyObject) -> String? {
return obj as? String
}
func toJSON(obj: AnyObject) -> [String: AnyObject]? {
return obj as? [String: AnyObject]
}
@ghthor
ghthor / NSURLComponents+URLQueryEncoding.h
Created March 8, 2016 15:45
ObjC URL Query String builder
//
// NSURLComponents+URLQueryEncoding.h
//
// Created by Willa Drengwitz on 3/8/16.
// Copyright © 2016 Willa Drengwitz. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSURLComponents (URLQueryEncoding)
// Go solution to https://projecteuler.net/problem=40
package main
import (
"fmt"
"log"
"strconv"
)
func main() {
@ghthor
ghthor / scbw.desktop
Created March 13, 2015 22:06
Starcraft WINE Launcher
[Desktop Entry]
Name=broodwar
Exec=env WINEPREFIX="/home/ghthor/.scbw.wine32" WINEARCH=win32 PULSE_LATENCY_MSEC=60 wine /home/ghthor/.scbw.wine32/dosdevices/c:/sc/StarCraft/StarCraft.exe
Type=Application
StartupNotify=true
Path=/home/ghthor/.scbw.wine32/dosdevices/c:/sc/StarCraft
Icon=/home/ghthor/.scbw.wine32/dosdevices/c:/sc/StarCraft/scbw.png
Categories=Game;
@ghthor
ghthor / 5tosleep.sh
Last active August 29, 2015 14:13
Pick 5 random videos from my collection and play them, then shutdown my computer. I use it to fall asleep.
#!/bin/bash
# find all videos in $PWD/*
# randomize them
# pick 5 of them
# add the vlc quit signal
# vlc
# shut her down
find -name "*.mkv" | \
@ghthor
ghthor / monad.go
Last active August 29, 2015 14:13
Playing with monads in go. Trying to understand what they are.
package main
import (
"fmt"
"strings"
)
type stringMonad func(string) (string, error)
func removeString(s string) stringMonad {
@ghthor
ghthor / date_fixup.go
Created May 7, 2014 17:27
Script To reformat all directories in a directory tree from $PWD/01-02-2006* -> $PWD/2006-01-02
package main
import (
"bufio"
"fmt"
"log"
"os"
"path/filepath"
"strings"
"time"
@ghthor
ghthor / PoE.ahk
Created February 27, 2013 15:57
Path of Exile Mouse Rebinds
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Recommended for catching common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#IfWinNotActive, Path of Exile
MButton::ScrollLock
#IfWinActive, Path of Exile
XButton1::ScrollLock
@ghthor
ghthor / gist:4514309
Last active December 11, 2015 00:09
Useful Vim Commands
" Move All go Functions to the end of the file
g/func/-1,/^}$/m$
@ghthor
ghthor / own3d-stream.py
Created October 14, 2012 01:44
Own3d Stream Export
#! /usr/bin/python2
import re
import sys
import urllib
import urllib2
from xml.dom.minidom import parseString
def printRtmpdumpCommand(rtmpUrl, app, streamId, channel):