Skip to content

Instantly share code, notes, and snippets.

View kevinmcmahon's full-sized avatar

Kevin McMahon kevinmcmahon

View GitHub Profile
@kevinmcmahon
kevinmcmahon / coloredlogcat.py
Created January 19, 2012 20:31
Colored Logcat
#!/usr/bin/python
'''
Copyright 2009, The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@kevinmcmahon
kevinmcmahon / organize-photos.py
Created February 8, 2016 21:36 — forked from cliss/organize-photos.py
Photo management script. This script will copy photos from "~/Pictures/iPhone Incoming" into a tree the script creates, with folders representing month and years, and photo names timestamped. Completely based on the work of the amazing Dr. Drang; see here: http://www.leancrew.com/all-this/2013/10/photo-management-via-the-finder/ You can see more…
#!/usr/bin/python
import sys
import os, shutil
import subprocess
import os.path
from datetime import datetime
######################## Functions #########################
@kevinmcmahon
kevinmcmahon / gist:3613612
Created September 3, 2012 21:14
Initialization of Location Services
- (void)initializeLocationServices {
// Check to ensure location services are enabled
if(![CLLocationManager locationServicesEnabled]) {
[self showAlertWithMessage:@"You need to enable location services to use this app."];
return;
}
if(![CLLocationManager regionMonitoringAvailable]) {
[self showAlertWithMessage:@"This app requires region monitoring features which are unavailable on this device."];
return;
@kevinmcmahon
kevinmcmahon / Macros.h
Created April 6, 2012 18:01
Objective-C Macros
/*
The MIT License (MIT)
Copyright (c) 2012 Kevin McMahon
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION W
@kevinmcmahon
kevinmcmahon / gist:1585171
Created January 9, 2012 21:56
Spatial query that finds all the landmarks in the 43rd Ward of Chicago.
SELECT landmarks.name, landmarks.architect, landmarks.address
FROM landmarks,wards
WHERE ST_Contains(wards.the_geom, landmarks.the_geom) AND wards.ward = '43';
@kevinmcmahon
kevinmcmahon / gist:1585140
Created January 9, 2012 21:50
Spatial query to find 5 closest landmarks to a lat/long in Chicago
-- distance units in planar degrees. 4326 is WGS 84 and the long lat units are degrees
SELECT
ST_Distance(ST_GeomFromText('POINT(-87.6348345 41.8786207)', 4326), landmarks.the_geom) AS planar_degrees,
name,
architect
FROM landmarks
ORDER BY planar_degrees ASC
LIMIT 5;
@kevinmcmahon
kevinmcmahon / gist:1584998
Created January 9, 2012 21:21
Updating the landmarks table to set the_geom column with POINT data.
UPDATE landmarks
SET the_geom = ST_GeomFromText('POINT(' || longitude || ' ' || latitude || ')',4326);
@kevinmcmahon
kevinmcmahon / gist:1584983
Created January 9, 2012 21:16
PostgreSQL copy command for importing CSV data.
\copy landmarks(name,address,date_built,architect,landmark,latitude,longitude) FROM '/local/path/to/Individual_Landmarks.csv' DELIMITERS ',' CSV HEADER;
#
# bash completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# *) local and remote branch names
@kevinmcmahon
kevinmcmahon / gist:1014915
Created June 8, 2011 17:48
C# IfModifiedSince
public static void Main (string[] args)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://example.com/file.xml");
// Note that previousValue is a DateTime now!
request.IfModifiedSince = DateTime.Now;
try
{
using (WebResponse response = request.GetResponse())