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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mlevans
mlevans / boston_neighborhoods.geojson
Created March 7, 2014 15:00
Neighborhood Boundaries for Boston
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mlevans
mlevans / flatten.py
Last active December 19, 2015 20:09
flatten an irregular multidimensional list
import collections
def flatten(x):
if isinstance(x, collections.Iterable):
return [a for i in x for a in flatten(i)]
else:
return [x]
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.
@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]>
<html>
<head>
<style type="text/css">
#over{
position: absolute;
left: 20;
}
</style>
<script type="text/javascript">
@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);
@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: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)
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