This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Using SSH, create a SOCKS4/5 proxy connection to a remote server and configure the system to use it. | |
_pgrep() { | |
P_CMD=$1 | |
P_PID=$( ps -u $USER -o pid,command | grep "${P_CMD}" | grep -v grep | head -1 | awk '{ print $1 }' ) | |
echo "$P_PID" | |
if [ -z $P_PID ]; then return 1; else return 0; fi | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
from errno import * | |
class SymlinkKVS(object): | |
def __init__(self, storepath): | |
self.storepath = storepath | |
def __delitem__(self, key): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MAILDIR="~/Maildir" | |
RESULTS="~/Maildir/.SearchResults" | |
mu find -o links --linksdir="${RESULTS}" --clearlinks $@ && mutt -f "${RESULTS}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
HOSTNAME=$(hostname -f) | |
GREEN=$( tput setaf 10 ) | |
CYAN=$( tput setaf 14 ) | |
RED=$( tput setaf 1 ) | |
GRAY=$( tput setaf 8 ) | |
RESET=$( tput setaf 7 ) | |
NAME=$( basename "$0" ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _HELPER(x) #x | |
#define START_IGNORE_DIAGNOSTIC(diag) _Pragma("clang diagnostic push"); _Pragma(_HELPER(clang diagnostic ignored #diag)); | |
#define STOP_IGNORE_DIAGNOSTIC _Pragma("clang diagnostic pop"); | |
START_IGNORE_DIAGNOSTIC(-Wsomething-stupid) | |
somethingSeeminglyStupid(); | |
STOP_IGNORE_DIAGNOSTIC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface NSString (IndexedAccessors) | |
- (id)objectAtIndexedSubscript:(NSUInteger)idx; | |
- (id)objectForKeyedSubscript:(id)key; | |
@end | |
@implementation NSString (IndexedAccessors) | |
- (id)objectAtIndexedSubscript:(NSUInteger)idx { return @([self characterAtIndex:idx]); } | |
- (id)objectForKeyedSubscript:(id)key { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(id)forwardingTargetForSelector:(SEL)aSelector | |
{ | |
// Do we have a scroll view delegate? | |
if (_scrollViewDelegate && [_scrollViewDelegate conformsToProtocol:@protocol(UIScrollViewDelegate)]) { | |
// Is this a selector in that protocol? | |
struct objc_method_description methodDescription = protocol_getMethodDescription(@protocol(UIScrollViewDelegate), aSelector, NO, YES); | |
if (methodDescription.name != NULL) return _scrollViewDelegate; | |
} | |
return [super forwardingTargetForSelector:aSelector]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function make_icon { | |
sips -s format png -Z $3 "$1" --out "$2" | |
pngcrush -ow -q "$2" | |
} | |
echo "Using $1 as the base image." | |
echo "** App Store: iTunesArtwork **" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <objc/objc.h> | |
#import <objc/objc-class.h> | |
#import <malloc/malloc.h> | |
#pragma mark Keyed Object | |
@interface KeyedObject : NSObject | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# Copyright (c) 2013 Adam Knight | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: |