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 / 2012-09-19_01-11-28-PM_ffmpeg-udp-broadcast-188-byte-packets
Created September 19, 2012 17:11
To stream in mpegts format over UDP using 188 sized UDP packets, using a large input buffer
ffmpeg -re -i <input> -f mpegts udp://<hostname>:<port>?pkt_size=188&buffer_size=65535
@kevinkirkup
kevinkirkup / gist:3758013
Created September 20, 2012 20:01
Get the next Meeting from iCal
set theNextOrCurrentEvent to (do shell script "/usr/local/bin/icalBuddy -ic \"Calendar\" -eep \"*\" -nc -b \"\" -n -li 1 eventsToday")
// From: http://useyourloaf.com/blog/2010/10/04/swiping-to-delete-rows-from-a-table.html
/**
* Perform anything that needs to be done before the Delete button is shown
*/
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView
editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
/* Do Stuff */
// AppDelegate is a Singleton
YourAppDelegate *appDelegate = (YourAppDelegate *)[[UIApplication sharedApplication] delegate];
// 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.
@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];
// ...
}
@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 / 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: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 / 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>;