Skip to content

Instantly share code, notes, and snippets.

@snown
snown / du-sorted
Created February 10, 2014 22:00
A quick (and possibly inefficient) shell script to output the `du` command sorted by human readable file size.
#!/usr/bin/env bash
du -sk "$@" | sort -nr | cut -f2 | sed 's/.*/\"&\"/' | tr "\\n" " " | xargs du -sh
@snown
snown / UIGestureRecognizer+NSStringFunctions.h
Created February 18, 2014 17:29
A UIGestureRecognizer Category to generate NSStrings for use with NSLog
#import <UIKit/UIKit.h>
@interface UIGestureRecognizer (NSStringFunctions)
/**
* Returns a string formatted to display the pertenent name of the
* `UIGestureRecognizerState`
*
* Often this just returns the text of the variable name after
* "UIGestureRecognizerState". For Example, `UIGestureRecognizerStatePossible`

Keybase proof

I hereby claim:

  • I am snown on github.
  • I am logan (https://keybase.io/logan) on keybase.
  • I have a public key whose fingerprint is 82AF 6207 4B8F E5D5 EC87 F8E3 8FF8 576D 0053 32A7

To claim this, I am signing this object:

@snown
snown / Interceptor.m
Created March 31, 2014 21:21
Non functional sample code
@implementation Interceptor
+ (IMP)instanceMethodForSelector:(SEL)aSelector {
NSLog(@"instanceMethodForSelector:");
IMP result = [super instanceMethodForSelector:aSelector];
NSLog(@"+[super instanceMethodForSelector:%@] = %p", NSStringFromSelector(aSelector), result);
return result;
}
@snown
snown / MTRXAnimatedViewLayer.m
Last active August 29, 2015 14:01
Deceivingly simple answer to a view animation that keeps it's content in the same visual place as the view frame moves.
- (void)addAnimation:(CAAnimation *)anim forKey:(NSString *)key {
DDLogVerboseMethodCall(@" %@", [anim debugDescription]);
CAAnimation *finalAnim = anim;
if ([key isEqualToString:@"position"] && [anim isKindOfClass:[CABasicAnimation class]]) {
CABasicAnimation *contentsRectAnim;
CALayer *presentationLayer = [self presentationLayer];
if (presentationLayer) {
contentsRectAnim = [anim copy];
contentsRectAnim.keyPath = @"contentsRect";
@snown
snown / Array+prepend
Last active August 29, 2015 14:02
A little extension to Array to allow prepending an item. This is just an experiment, not necessarily the right way to do it.
extension Array {
mutating func prepend(newitem: T) {
insert(newitem, atIndex: 0)
}
mutating func prepend(itemArray: Array) {
for (index, item) in enumerate(itemArray) {
insert(item, atIndex: index)
}
}
}
@snown
snown / launch-list.sh
Created September 28, 2014 00:39
A script to search both root and user launchctrl scripts currently registered with the system
#!/usr/bin/env bash
LAUNCH_LIST_PATH=/tmp/launchList
touch $LAUNCH_LIST_PATH
launchctl list > $LAUNCH_LIST_PATH
sudo launchctl list >> $LAUNCH_LIST_PATH
head -n 1 $LAUNCH_LIST_PATH
grep "$@" $LAUNCH_LIST_PATH
@snown
snown / UITextView+MTRXUILabel.h
Created October 1, 2014 19:20
UITextView Category for initializing a text view with a specified UILabel object
//
// UITextView+MTRXUILabel.h
// Site Survey
//
// Created by Logan Holmes on 10/1/14.
// Copyright (c) 2014 Logan Holmes. All rights reserved.
//
#import <UIKit/UIKit.h>
@snown
snown / AccountController.php
Created March 15, 2015 01:40
FatalErrorException in AccountController.php: Class 'App\Facades\QueryCache' not found
<?php namespace App\Http\Controllers;
use App\Facades\QueryCache;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Models\Account;
use DebugBar\DebugBar;
use Illuminate\Database\Eloquent\Builder as EloquentQuery;
@snown
snown / gist:1045269
Created June 24, 2011 17:37
Start up and shutdown FlexRAID with computer
# flexraid - start/stop FlexRAID 2.0
#
# This service starts up the FlexRaid process so that RAIDing of Data drives can resume
description "FlexRAID 2.0"
author "Logan Holmes"
start on runlevel [2345]
stop on runlevel [06]