Skip to content

Instantly share code, notes, and snippets.

View mlevans's full-sized avatar

Michael Lawrence Evans mlevans

  • Office of Emerging Technology, City of Boston
  • Boston, MA
View GitHub Profile
@mlevans
mlevans / gist:3288218
Created August 7, 2012 18:43
Find Random Map Tiles in the United States
import random
import ModestMaps
# import whereami # this script borrows bits from whereami: https://github.com/migurski/whereami
# Using rough boundaries of the United States
lat_bounds = [32,41.5]
lng_bounds = [-116.5,-80]
num_of_places = 1000
@mlevans
mlevans / gist:3318783
Created August 10, 2012 22:58
Get a chunk of 100,000 lines from a text file (from line 500000)
head -n 500000 larger_file.txt | tail -n 100000 > smaller_file.txt
@mlevans
mlevans / gist:3725694
Created September 15, 2012 00:06
Xcode 4.2 installed, but I need gcc-4.2
In a temporary directory:
curl -O http://opensource.apple.com/tarballs/gcc/gcc-5666.3.tar.gz
tar zxf gcc-5666.3.tar.gz
cd gcc-5666.3
mkdir -p build/obj build/dst build/sym
gnumake install RC_OS=macos RC_ARCHS='i386 x86_64' TARGETS='i386 x86_64' SRCROOT=`pwd` OBJROOT=`pwd`/build/obj DSTROOT=`pwd`/build/dst SYMROOT=`pwd`/build/sym
sudo ditto build/dst /
class GradeLevel
attr_accessor :number
def initialize(num)
@number = num
end
def order_index
number =~ /K(\d)/ ? $1.to_i : (number.to_i + 2)
end
end
@mlevans
mlevans / gist:3808891
Last active October 11, 2015 05:17
Postgres.app with PostGIS on MacOS X Lion
Running locally on MacOS X Lion
1. You may have postgres running locally on your machine on port 5432. We'll need to shut it down,
since we're going to use Postgres.app (postgresapp.com). I had previously downloaded PostgreSQL
from EnterpriseDB (http://enterprisedb.com/downloads/postgres-postgresql-downloads).
This was my process.
- `cd /Library/PostgreSQL/9.1/bin`
- Find out where postgres stores your data with `ps aux | grep postgres` (My data was in /Library/PostgreSQL/9.1/data)
@mlevans
mlevans / index.html
Created November 2, 2012 22:42 — forked from zzolo/index.html
A basic pack layout with D3
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>MinnPost</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">var _sf_startpt=(new Date()).getTime()</script>
<link rel="shortcut icon" href="http://www.minnpost.com//sites/default/themes/siteskin/favicon.ico" type="image/x-icon" />
<meta name="keywords" content="Mark Dayton,Minnesota DFL,Minnesota GOP,Minnesota Legislature,Vikings Stadium,Voter ID Amendment" />
@mlevans
mlevans / gist:4487402
Created January 8, 2013 20:02
Leaflet zoom-by-about function
// Stubbed out for now; this assumes that map is global and initialized.
// It also assumes that you're using jQuery or Zepto.
function zoomByAbout(e) {
var x = .5*$('#map').width(),
y = .5*$('#map').height(),
mouse_point = e.containerPoint,
new_center_point = new L.Point((x + mouse_point.x) / 2, (y + mouse_point.y) / 2),
new_center_location = map.containerPointToLatLng(new_center_point);
<html>
<head>
<style type="text/css">
#over{
position: absolute;
left: 20;
}
</style>
<script type="text/javascript">
@mlevans
mlevans / index.html
Created March 26, 2013 21:44
Linking to a new map with the same center (for Bill)
<!DOCTYPE html>
<html>
<head>
<title>Linking to a new map with the same center</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.5/leaflet.css" />
<!--[if lte IE 8]>
How to create an animated gif using iMovie and Photoshop (yes I don't have After Effects otherwise this would be super easy)...
1) Open iMovie. Import movie as a new event and add it to a new Project, editing the clip as necessary
2) Go to Projects list, right click on appropriate project and 'Export using Quicktime', select the 'Image Sequence' file type and I would advise setting the fps to around 6-12 (you can do this by clicking 'Advanced'). Once saved you will see you have a bunch of images...
3) Now to Photoshop. Go to File > Scripts > Load files into Stack, to open all frame files into one document as individual layers.
4) Open the Animation panel, and by clicking the options icon, select 'Document Options...' Set the fps to the same as the Image Sequence.