Skip to content

Instantly share code, notes, and snippets.

View kevinkirkup's full-sized avatar

Kevin S Kirkup kevinkirkup

  • Digital Realty Trust
  • Raleigh, NC
View GitHub Profile
@kevinkirkup
kevinkirkup / HomeBrew_Python_Setup
Created February 17, 2014 21:41
Homebrew Python Bindings setup
# Subversion Python bindings example
brew install subversion --with-python
mkdir -p ~/Library/Python/2.7/lib/python/site-packages
echo $(brew --cellar)/subversion/1.8.5/lib/svn-python \
> ~/Library/Python/2.7/lib/python/site-packages/svn.pth
@kevinkirkup
kevinkirkup / UDPClient.py
Created November 26, 2013 05:05
Python UDP Client Example
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
while True:
msg = raw_input('--> ')
s.sendto(msg, ('0.0.0.0', 9601))
finally:
s.close()
@kevinkirkup
kevinkirkup / UDPServer.py
Created November 26, 2013 05:04
Python UDP Server Example
'Show how to make a UDP server'
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(('', 9601))
try:
while True:
msg, who = s.recvfrom(256)
print 'Received a call from: %r' % (who,)
SELECT * FROM query_to_xml('SELECT * from <table>;', <boolean null>, <boolean tableforest>, '');
@kevinkirkup
kevinkirkup / PostgreSQL_AutoIncrement.sql
Created November 26, 2013 04:58
PostgreSQL AutoIncrement
CREATE SEQUENCE <field_seq>;
ALTER TABLE <table>
ALTER COLUMN <field> TYPE SMALLINT USING <field>::integer
, ALTER COLUMN <field> SET NOT NULL
, ALTER COLUMN <field> SET DEFAULT nextval('<field_seq>');
ALTER SEQUENCE <field_seq>
OWNED BY <table>.<field>;
@kevinkirkup
kevinkirkup / gist:5557770
Last active December 17, 2015 05:28
Timemachine script to mount TimeMachine backup disk and trigger a time machine backup.Had to make some modifications to put in in the OSX standard log location.Reference:http://hints.macworld.com/article.php?story=20100712085231232
#!/usr/bin/env python
# place in /etc/periodic/daily to run nightly (or hourly if set up):
#
# sudo cp -f timemachine.py /etc/periodic/daily/667.timemachine
# sudo cp -f timemachine.py /etc/periodic/hourly/667.timemachine
import re
import datetime
import time
@kevinkirkup
kevinkirkup / gist:4009790
Created November 4, 2012 01:56
UIImage blur filter
//http://stackoverflow.com/questions/8528726/does-ios-5-support-blur-coreimage-fiters
@interface UIImage (ImageBlur)
- (UIImage *)imageWithGaussianBlur9;
@end
@implementation UIImage (ImageBlur)
- (UIImage *)imageWithGaussianBlur9 {
float weight[5] = {0.2270270270, 0.1945945946, 0.1216216216, 0.0540540541, 0.0162162162};
// Blur horizontally
@kevinkirkup
kevinkirkup / gist:3907295
Created October 17, 2012 18:41
OSX Simple HTTP Server
# From: http://osxdaily.com/2010/05/07/create-an-instant-web-server-via-terminal-command-line/
python -m SimpleHTTPServer
# With port
python -m SimpleHTTPServer 8000
@kevinkirkup
kevinkirkup / 2012-10-17_08-51-17-AM_UITableViewCell_for_UIGestureRecognizer.m
Created October 17, 2012 12:53
Get UITableViewCell from UIGestureRecognizer
// Add the UIGestureRecognizer to the UITableView in viewDidLoad:
-(void)didSwipe:(UIGestureRecognizer *)gestureRecognizer {
if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
CGPoint swipeLocation = [gestureRecognizer locationInView:self.tableView];
NSIndexPath *swipedIndexPath = [self.tableView indexPathForRowAtPoint:swipeLocation];
UITableViewCell* swipedCell = [self.tableView cellForRowAtIndexPath:swipedIndexPath];
// ...
}
// From: http://mobile.tutsplus.com/tutorials/iphone/ios-sdk_nsnotificationcenter/
// Add Methods to post and handle notifications
@interface ViewController ()
- (void)postNotificationWithString:(NSString *)orientation;
- (void)useNotificationWithString:(NSNotification*)notification;
@end
/**
* Register for notifications.