Skip to content

Instantly share code, notes, and snippets.

def trans_lat(lat)
lat =~ /([0-9]+)([NS])/
num, dir = $1.to_i, $2
dir == 'S' ? -num : num
end
def trans_long(long)
long =~ /([0-9]+)([EW])/
def create_spatial_database_template():
sudo("""createdb -E UTF8 template_postgis -U postgres""")
try:
sudo("""createlang -d template_postgis plpgsql -U postgres""")
except:
pass
sudo("""psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql -U postgres""")
sudo("""psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql -U postgres""")
sudo("""psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;" -U postgres""")
sudo("""psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;" -U postgres""")
@adamfast
adamfast / requiredreading.txt
Created July 6, 2012 15:20
Preserved for #lawrence history, this was the "required reading" list of totally-non-work-related inside jokes of the World Online crew.
DJ Ango, yo!
http://railsenvy.com/2007/9/10/ruby-on-rails-vs-django-commercial-7
The Whistles
[now broken] http://www.youtube.com/watch?v=ccgXjA2BLEY
http://www.youtube.com/watch?gl=US&hl=en&client=mv-google&v=Nnzw_i4YmKk
Do it live!
http://www.youtube.com/watch?v=2tJjNVVwRCY
REMIX: http://www.youtube.com/watch?v=5j2YDq6FkVE&NR=1
@adamfast
adamfast / date.js
Created January 15, 2011 16:48
Using date.js in node.js
/**
* Version: 1.0 Alpha-1
* Build Date: 13-Nov-2007
* Copyright (c) 2006-2007, Coolite Inc. (http://www.coolite.com/). All rights reserved.
* License: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/.
* Website: http://www.datejs.com/ or http://www.coolite.com/datejs/
*/
Date.CultureInfo={name:"en-US",englishName:"English (United States)",nativeName:"English (United States)",dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbreviatedDayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],shortestDayNames:["Su","Mo","Tu","We","Th","Fr","Sa"],firstLetterDayNames:["S","M","T","W","T","F","S"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],abbreviatedMonthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],amDesignator:"AM",pmDesignator:"PM",firstDayOfWeek:0,twoDigitYearMax:2029,dateElementOrder:"mdy",formatPatterns:{shortDate:"M/d/yyyy",
I needed to find info on a sequence that was causing problems with one of our apps, and couldn't find any info online. Here's what I ended up doing.
\d <sequence> wasn't telling me anything except that it did exist. I couldn't find out what was using it in order to determine if it was safe to eliminate.
select oid from pg_class where relname='<sequence>'; # retrieves the internal ID in PostgreSQL
select refobjid from pg_depend where objid = <found_oid>; # retrieve depenencies for the sequence in question.
select relname from pg_class where oid in (<ref_oid1>, # ... if others); # get the names that are linking to it
\d <found_tables> for each item found above - see if there's any mention of the index blowing up.
OR, after figuring this out, I kept working. Here's one query to rule them all:
git config --global branch.autosetuprebase always