Skip to content

Instantly share code, notes, and snippets.

View kevinmcmahon's full-sized avatar

Kevin McMahon kevinmcmahon

View GitHub Profile
@kevinmcmahon
kevinmcmahon / gist:957507
Created May 5, 2011 17:45
rack-jekyll issue?
2011-05-05T17:44:15+00:00 app[web.1]: Configuration from /app/_config.yml
2011-05-05T17:44:16+00:00 app[web.1]: /usr/ruby1.8.7/lib/ruby/1.8/fileutils.rb:243:in `mkdir': Permission denied - /app/_site (Errno::EACCES)
2011-05-05T17:44:16+00:00 app[web.1]: from /usr/ruby1.8.7/lib/ruby/1.8/fileutils.rb:243:in `fu_mkdir'
2011-05-05T17:44:16+00:00 app[web.1]: from /usr/ruby1.8.7/lib/ruby/1.8/fileutils.rb:217:in `mkdir_p'
2011-05-05T17:44:16+00:00 app[web.1]: from /usr/ruby1.8.7/lib/ruby/1.8/fileutils.rb:215:in `reverse_each'
2011-05-05T17:44:16+00:00 app[web.1]: from /usr/ruby1.8.7/lib/ruby/1.8/fileutils.rb:215:in `mkdir_p'
2011-05-05T17:44:16+00:00 app[web.1]: from /usr/ruby1.8.7/lib/ruby/1.8/fileutils.rb:201:in `each'
2011-05-05T17:44:16+00:00 app[web.1]: from /usr/ruby1.8.7/lib/ruby/1.8/fileutils.rb:201:in `mkdir_p'
2011-05-05T17:44:16+00:00 app[web.1]: from /app/.gems/gems/jekyll-0.10.0/lib/jekyll/post.rb:198:in `write'
2011-05-05T17:44:16+00:00 app[web.1]: from /app/.gems/gems/jekyll-0.10.0/lib/jekyll/
@kevinmcmahon
kevinmcmahon / gist:1005881
Created June 3, 2011 04:42
Android If-Modified-Since
HttpClient httpClient = new DefaultHttpClient();
HttpHead httpHead = new HttpHead(accountUrl);
long date = cachedFile.lastModified();
String lastModified = DateUtils.formatDate(new Date(date), "EEE, d MMM yyyy HH:mm:ss 'GMT'");
httpHead.addHeader("If-Modified-Since", lastModified);
HttpResponse response = httpClient.execute(httpHead);
int statusCode = response.getStatusLine().getStatusCode();
return statusCode != HttpStatus.SC_NOT_MODIFIED;
@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())
#
# 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:1584721
Last active December 15, 2019 23:08
Create a PostgreSQL table to hold the Individual_Landmarks.csv data
CREATE TABLE landmarks
(
gid serial NOT NULL,
name character varying(50),
address character varying(50),
date_built character varying(10),
architect character varying(50),
landmark character varying(10),
latitude double precision,
longitude double precision,
@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;
@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: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: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 / 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