Skip to content

Instantly share code, notes, and snippets.

View keith's full-sized avatar

Keith Smiley keith

View GitHub Profile
@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 / methods.rb
Created September 26, 2012 19:08
Prints ObjC method names to a file
#!/usr/bin/ruby
#
# This is a simple script for printing out the methods in your Objective-C .h or .m file.
# It reads the passed file and stores just the method names in a text file
#
# Default filename and type for the file output
$DEFAULT_FILENAME = "out_file"
$DEFAULT_FILE_EXTENSION = "txt"
@keith
keith / googleReaderOPML.rb
Created October 11, 2012 19:57
A Ruby script to export your Google Reader subscriptions to OPML
#!/usr/bin/env ruby
#
# => This script will authorize your Google credentials and download your Google Reader subscriptions
# => Usage: ./SCRIPTNAME GOOGLEUSERNAME PASSWORD
#
# The required networking shenanigans
require 'uri'
require 'net/http'
@keith
keith / FinderWindows.applescript
Created November 6, 2012 15:16
Align your Finder windows side-by-side
-- By: @SmileyKeith
-- Vertically distributes your open finder windows for easy file movements
-- Thanks to @elasticthreads
tell application "Finder"
-- Get the number of Finder windows
set window_count to (count every Finder window)
-- Make sure there is an open Finder window
if window_count > 0 then
@keith
keith / Rakefile
Created November 20, 2012 23:34
A rakefile to build your xcodeproject and place the result in your applications folder.
#!/usr/bin/env rake
require 'rubygems'
require 'fileutils'
# This requires the 'colorize' gem. Install with `[sudo] gem install colorize`
require 'colorize'
task :default => [:build]
@keith
keith / domainr.rb
Last active October 13, 2015 06:58
Use the Domai.nr API to see what domains are available.
#!/usr/bin/env ruby
# A tiny script to check available domain names
# Uses the Domai.nr API http://domai.nr/api/docs/json
# A blatent ripoff of http://blog.jerodsanto.net/2012/11/a-domainr-cli-in-less-than-15-lines-of-ruby/
require 'rubygems'
require 'open-uri'
# `[sudo] install colorize json`
@keith
keith / showHideMainWindow.m
Last active December 10, 2015 05:58
Global shortcut show hide window method
- (void)showHideMainWindow {
NSNumber *wasActive = @NO;
if ([[NSRunningApplication currentApplication] isActive]) {
wasActive = @YES;
NSNumber *wasOpen = @NO;
if ([self.window isVisible]) {
wasOpen = @YES;
[self.window close];
[[NSApplication sharedApplication] hide:self];
} else if (![wasOpen boolValue]) {
@keith
keith / goodVimKeysSandbox.mm
Last active December 10, 2015 20:28
http://smileykeith.com/2013/01/08/nstableview-vim-keys/ Override keyDown to use vim keys in something. Like an NSTableView. Only goodVimKeysSandbox.mm works perfectly in the OS X sandbox.
if ([theEvent keyCode] == 38) { // j
unichar down = NSDownArrowFunctionKey;
NSString *downString = [NSString stringWithCharacters:&down length:1];
NSEvent *newEvent =[NSEvent keyEventWithType:NSKeyDown
location:theEvent.locationInWindow
modifierFlags:theEvent.modifierFlags
timestamp:theEvent.timestamp
windowNumber:theEvent.windowNumber
context:nil
characters:downString
@keith
keith / googleReaderOPML.rb
Created February 1, 2013 17:29
Export your google reader subscriptions to an OPML file
#!/usr/bin/env ruby
#
# => This script will authorize your Google credentials and download your Google Reader subscriptions
# => Usage: ./googleReaderOPML.rb GOOGLEUSERNAME PASSWORD
#
# The required networking shenanigans
require 'uri'
require 'net/http'
@keith
keith / compressjs.sh
Created July 2, 2013 19:14
Compresses Javascript using YUI Compressor. Expects the compiled YUI Compressor jar file to be in the same directory as the executed script
#!/usr/bin/env bash
die() {
echo "Usage $(basename $0) [infile] [outfile]"
exit
}
if [[ $# -lt 1 ]];then
die
fi