Skip to content

Instantly share code, notes, and snippets.

View ajturner's full-sized avatar
🗺️
Considering WhereCamps

Andrew Turner ajturner

🗺️
Considering WhereCamps
View GitHub Profile
@codepo8
codepo8 / localstorage.js
Created August 25, 2010 14:44
Store the state of a rendered form the easy way
<script>
// test for localStorage support
if(('localStorage' in window) && window['localStorage'] !== null){
var f = document.getElementById('mainform');
// test with PHP if the form was sent (the submit button has the name "sent")
<?php if(isset($_POST['sent']))){?>
// get the HTML of the form and cache it in the property "state"
localStorage.setItem('state',f.innerHTML);
@pjb3
pjb3 / open_method_def_in_textmate.rb
Created March 9, 2011 22:54
You can find at runtime where a method was defined. This is a little hack to then open that method in textmate
> m = 2.days.method(:ago)
=> #<Method: Fixnum(ActiveSupport::CoreExtensions::Numeric::Time)#ago>
> m.__file__
=> "/Users/paul/.rvm/gems/ree-1.8.7-2011.03@deals/gems/activesupport-2.3.5/lib/active_support/core_ext/numeric/time.rb"
> m.__line__
=> 64
> class Method; def open_in_textmate; `mate -l #{__line__} #{__file__}`; end; end
=> nil
> 2.days.method(:ago).open_in_textmate
=> ""
@tecoholic
tecoholic / osm2geo.js
Created November 27, 2011 04:57
OSM2GEO - A JS Converter to convert OSM to GeoJSON
/**************************************************************************
* OSM2GEO - OSM to GeoJSON converter
* OSM to GeoJSON converter takes in a .osm XML file as input and produces
* corresponding GeoJSON object.
*
* AUTHOR: P.Arunmozhi <aruntheguy@gmail.com>
* DATE : 26 / Nov / 2011
* LICENSE : WTFPL - Do What The Fuck You Want To Public License
* LICENSE URL: http://sam.zoy.org/wtfpl/
*
@sgillies
sgillies / geo_interface.rst
Last active May 29, 2024 12:49
A Python Protocol for Geospatial Data

Author: Sean Gillies Version: 1.0

Abstract

This document describes a GeoJSON-like protocol for geo-spatial (GIS) vector data.

Introduction

@bigeasy
bigeasy / .bash_profile
Created June 27, 2012 17:44
hidegrep
# Add to your `.bash_profile`. If you do something that is incredibly
# destructive, like `git push --force origin HEAD`, you can then
# delete it, how ever many times you've run it, from your history
# using `hidegrep --force`.
function hidegrep()
{
while true; do
hist=$(history | grep -e "$1" | head -n 1)
if [ -z "$hist" ]; then break; fi
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@tmcw
tmcw / README.md
Created September 21, 2012 03:45
OSM Growth

What is this? It's about 7 years of OpenStreetMap growth. Each step in the animation is 72 days, and the colors alternate between red and blue. The data is from Latest Weekly Changesets from planet.openstreetmap.org, processed into an SQLite database with sometimemachine. The points being drawn are the centers of the bounding boxes of changesets. There are 13,098,655 changesets in the database. The script to generate the visualization is below, and the rest of the make steps are

gm mogrify -format gif *.png
gifsicle --loop -d20 *.gif > ../animation.gif

Requiring gifsicle and graphicsmagick.

Fast growth in rectangular areas (like the DRC) is typically because of imports to the OSM data from other open datasources. The d

@max-mapper
max-mapper / blink-led.js
Last active April 13, 2022 20:30
raspberry pi scripts

The command I used to estimate the size once gzipped is gzip -c filename.min.js | wc -c. Every library except open layers includes it CSS in the total size. Esri Standard includes the Claro widget theme but compact does not.

@oevans
oevans / AGO_PullHostedFeatures.py
Last active April 16, 2024 18:37
Python script to pull hosted features with attachments into a local file geodatabase. See ReadMe below.
import os, urllib, urllib2, datetime, arcpy, json
## ============================================================================== ##
## function to update a field - basically converts longs to dates for date fields ##
## since json has dates as a long (milliseconds since unix epoch) and geodb wants ##
## a proper date, not a long.
## ============================================================================== ##
def updateValue(row,field_to_update,value):
outputfield=next((f for f in fields if f.name ==field_to_update),None) #find the output field