Skip to content

Instantly share code, notes, and snippets.

View carsonfarmer's full-sized avatar
🏖️
Remote working...

Carson Farmer carsonfarmer

🏖️
Remote working...
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@carsonfarmer
carsonfarmer / README.md
Last active September 26, 2016 03:37
After the Irish Famine

After the Irish Famine

This is a simple visualization of population change in Ireland during the [Great Famine][] era. It uses continuous area cartograms and population estimates from 1841 to 2001 to demonstrate change. The cool thing about this visualization is how dramatically it emphasizes population loss from 1841 to 1851 (and beyond), and how, even in modern Ireland, many counties remain well below their pre-famine population levels. As a whole, the population of Ireland remains less than 70% of its pre-famine levels!

A popover gives you additional information on mouse over. This includes county name, total population for the give year, and a nice little [sparkline][] showing population change over time (with the current year highlighted for reference). This gives a nice quick feel for the population change over time, and was pretty easy to do using D3js and Twitter Bootstrap.

This visualization uses [D3js][], [colorbrewer][], Twitter's [Bootstrap][], [jQuery][], and some helpful examples from [here

@carsonfarmer
carsonfarmer / README.md
Last active February 8, 2016 03:56
CitiBike Trips

CitiBike trips by Neighborhood

Mouseover to focus on rides to or from a single neighborhood.

The thickness of links between neighborhoods encodes the relative frequency of rides between two neighborhoods: thicker links represent more frequent rides. Only flows that represent more than 1000 trips are represented here to avoid too many small flows.

Links are directed: for example, while 0.5% of rides go from Midtown to the Flatiron District, only 0.4% go in the opposite direction. Links are colored by the more frequent origin.

This may not be the best visualisation for this type of data, particularly given how dense the connectivity matrix is. However, it does present a quick and fun way to checkout the CitiBike data at an aggregate level.

@carsonfarmer
carsonfarmer / README.md
Last active October 14, 2020 18:53
Chord flow diagram with time slider

CitiBike trips by Neighborhood over time

May 1st, 2014 - Carson Farmer

Mouseover to focus on rides to or from a single neighborhood.

The thickness of links between neighborhoods encodes the relative frequency of rides between two neighborhoods: thicker links represent more frequent rides. Only flows that represent more than 1000 trips are represented here to avoid too many small flows.

Links are directed, and are colored by the more frequent origin (i.e., where most of the trips originate from). Colors themselves are pretty much arbitrary.

You can move the slider around to change which year/month is shown. Play around by sliding around and comparing flows over different time periods. Also watch for chord 'flipping', where the dominant flow direction changes from month to month. This is particularly common in the smaller flows, where there isn't a strong dominant direction.

@carsonfarmer
carsonfarmer / README.md
Last active August 29, 2015 14:01
Halton Sequence for Pseudo-random Points

Halton Sequence for Pseudo-random Points

May 18th, 2014 - Carson Farmer

The two point patterns here are the first 256 points from a 2, 3 Halton Sequence (left), and 256 points from a uniform random point process (right).

Halton sequences are often used to generate points in space for numerical methods such as Monte Carlo simulations. Although these sequences are deterministic they are of low discrepancy, which means they appear to be random for many purposes. A particularly useful property of Halton sequences (and some other pseudo-random sequences) is that they have have a better coverage of the underlying space than 'true' random sequences. This is particularly useful for creating things like dot density maps, where we want a random feel without leaving gaps across the space (which may arise with random numbers).

@carsonfarmer
carsonfarmer / README.md
Last active August 29, 2015 14:01
Problems Creating A Dot Density Map With D3

Problems Creating A Dot Density Map With D3

Here is the topojson call to create the topojson file:

topojson -o us_states.topo.json --projection='width=960, height=600, d3.geo.albersUsa().scale(1280).translate([width/2,height/2])' --simplyfy=.5 --filter=none --id-property='NAME,Geography' --external-properties=census_2010s.csv -p population=+2013 -- states=us_states.json

This could obviously be quite a bit more efficient (by using a canvas for example), but serves to illustrate the application.

Right now the points are randomly placed on the bounds of each individual state. What is the most efficient way to clip the points to the individual state polygons? Is there a 'point in polygon' js library compatible with D3.js? Are there more efficient 'approximations' for this? Any and all thoughts are welcome!

@carsonfarmer
carsonfarmer / batkid.geojson
Last active August 29, 2015 14:03 — forked from anonymous/corpus copy.geojson
Tweets about #batkid
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@carsonfarmer
carsonfarmer / README.md
Last active October 23, 2019 22:21
A simple text-based clock using D3js

Text-Based Clock

A simple text-based clock that can be used as a Mac OSX Dashboard Widget

How to make the widget

  1. Clone this gist or click "Download Gist" on the right and extract the archive
  2. Copy the folder and its contents to somewhere 'safe' (i.e., where you won't delete it)
  3. Double click index.html to open the webpage in Safari
  4. Click the 'File' menu, then click 'Open in Dashboard...'
  5. Your screen will dim, and you can select the area you want to display in the widget
@carsonfarmer
carsonfarmer / run_remote_code.py
Last active August 29, 2015 14:15
A simple function that fetches a remote (or local) python file and runs it inside an IPython Notebook
def run_remote_code(url):
"""Fetch and run remote Python code.
This is a custom function that fetches
and runs remote Python code inside of an
IPython Notebook.
Careful, this could be super bad stuff!
"""
from IPython.core.magics.code import CodeMagics
@carsonfarmer
carsonfarmer / data.csv
Created February 25, 2015 03:29
5000 Tweets in NYC over Thanksgiving
id x y
0 -73.992191 40.739449
1 -73.018136 40.87074
2 -73.946186 40.632716
3 -73.880039 40.998842
4 -72.165523 41.422617
5 -73.82308 40.990214
6 -73.070623 40.760706
7 -73.980833 40.77083
8 -73.530004 40.873758