Skip to content

Instantly share code, notes, and snippets.

@rasmi
rasmi / README.md
Last active August 29, 2015 14:23 — forked from gisminister/README.md

The map shows traffic accidents recorded in Oslo, Norway, for the year 2013.

The Leaflet Markercluster plugin is wonderful. Since the markerclusters are divIcons you can put whatever you want inside them using the iconCreateFunction. I wanted my clusters to reveal more information than just the marker count and figured a pie chart would do the job. So I told the iconCreateFunction to do some D3 magic and this is the result.

The example is a bit more complicated than necessary due to how my dataset is structured. But if you take a look at the defineClusterIcon() function you'll see that I use d3.nest() to build a dataset for the pie chart based on a given property from all the cluster's children. Then I pass this dataset over to the bakeThePie() function together with instructions on how to style the chart. The function returns svg markup which in turn is placed inside the divIcon.

Feel free to suggest improvements.

Keybase proof

I hereby claim:

  • I am rasmi on github.
  • I am rasmi (https://keybase.io/rasmi) on keybase.
  • I have a public key whose fingerprint is 6224 68D7 CD9D D8A5 691A 8945 A808 3035 AEB7 46AE

To claim this, I am signing this object:

@rasmi
rasmi / GeorgePopulations.ipynb
Created May 2, 2016 00:02
GerogePopulations
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/env python
# halo_profiles.py
# Create halo profiles for gas, stars, and dm density for a given enzo directory.
# halo_profiles.py RD0006
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("directory", type=str, help="List one or more directories to analyze.")
args = parser.parse_args()
directory = args.directory
#!/usr/bin/env python
# findhalos.py
# Find halos for a given enzo directory.
# findhalos.py RD0006
import yt
from yt.analysis_modules.halo_analysis.api import HaloCatalog
from yt.analysis_modules.halo_analysis.halo_filters import add_filter
directory = 'RD0009'
#!/usr/bin/env python
# halo_gas_stars_dm_projections.py
# Create halo projections for gas, stars, and dm density for a given enzo directory.
# halo_projections.py RD0006
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("directory", type=str, help="List one or more directories to analyze.")
args = parser.parse_args()
directory = args.directory
@rasmi
rasmi / Heating.ipynb
Created September 18, 2016 17:15
Analyzing NYC Heating Code violations to predict future occurrences. Project by Rasmi Elasmar at HackMIT 2016.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# SEAS_evaluations.py
# https://github.com/rasmi
import json
import urllib2
import re
from bs4 import BeautifulSoup
site_url ='http://oracle.seas.columbia.edu/'
course_list_url = site_url + 'viewcourse_m.php'
course_sections_url = site_url + 'viewresults.php?course='
@rasmi
rasmi / facebook-mass-delete-group-members.js
Last active December 9, 2016 06:28 — forked from michaelv/facebook-mass-delete-group-members.js
This javascript removes all users from a facebook group. It works with the new facebook layout. Paste this in the javascript console. Script tested in Firefox. Known issues: 1. when facebook responds slowly, the script might experience hickups.. 2. occasionially, the error 'this user is not a member of the group' pops up.. IMPORTANT: add your ow…
var deleteAllGroupMembers = (function () {
var deleteAllGroupMembers = {};
// the facebook ids of the users that will not be removed.
// IMPORTANT: add your own facebook id here so that the script will not remove yourself!
var excludedFbIds = ['1150288216']; // make sure each id is a string!
var usersToDeleteQueue = [];
var scriptEnabled = false;
var processing = false;
deleteAllGroupMembers.start = function() {
@rasmi
rasmi / styles.css
Created December 10, 2016 18:31
Google Docs Minimal
/* Hide page break line */
.kix-page-compact::before {
border-style: none;
}
/* Hide Explore icon */
.docs-explore-widget {
display: none;
}