Skip to content

Instantly share code, notes, and snippets.

View espinielli's full-sized avatar

Enrico Spinielli espinielli

View GitHub Profile
@mbostock
mbostock / quantize.js
Last active February 9, 2016 01:20
Simplifying and cleaning Shapefiles.
us.coordinates = us.coordinates.map(function(polygon) {
return polygon.map(function(lineString) {
return lineString.map(function(point) {
return point.map(function(coordinate) {
return d3.round(coordinate, 2);
});
});
})
});
@cpsievert
cpsievert / europe.R
Last active December 1, 2017 23:05 — forked from halhen/europe.R
library(tidyverse)
library(plotly)
# I'm being lazy, please don't do this
# setwd("~/Downloads/Version 2_0_1/")
d <- read_csv('GEOSTAT_grid_POP_1K_2011_V2_0_1.csv') %>%
rbind(read_csv('JRC-GHSL_AIT-grid-POP_1K_2011.csv') %>%
mutate(TOT_P_CON_DT = '')) %>%
mutate(
@dwtkns
dwtkns / README.md
Last active May 28, 2019 06:59
Sun and Earth

Experiments faking 3d rotation of a globe and sun in SVG. Illusion is helped by dynamic gradients, two nested orthographic projections, scaling the sun circle's radius based on distance from the 'camera', and toggling a clipping mask that makes the sun appear to move "behind" the earth.

Based on Mike Bostock's Solar Terminator and this past experiment.

This example stems from drafts of maps for Norway the Slow Way. Also see Mike's Pencil Sketch example.

@jordan-brough
jordan-brough / instructions.markdown
Created November 3, 2012 13:50
Splunk-friendly timestamp plugin snippet for Sublime Text 2
  1. Choose: Tools > New Plugin

  2. Paste in the contents of "timestamp.py" below

  3. Save as timestamp.py in ~/Library/Application Support/Sublime Text 2/Packages/User/ (should be the default directory that pops up when you save)

  4. Choose: Sublime Text 2 > Preferences > Key Bindings - User

  5. Add:

    { "keys": ["super+ctrl+t"], "command": "timestamp" }

To make command+ctrl+t perform the insertion.
Make sure to add a comma after the previous keymap entry, if present.

@capesean
capesean / README.md
Last active April 21, 2020 01:18
TopoJSON Property Editor

TopoJSON Property Editor

  1. Supply the tool with some topoJSON data (via url or direct input), and it will draw the map.
  2. Click one of the shapes and you can view and edit the properties of the topoJSON object.
  3. Click the Output tab and you can copy the full, modified topoJSON.

View on http://bl.ocks.org/

library(rayshader)
library(sf)
library(ggmap)
library(EAlidaR)
# ------------ User Inputs ---------------------------------
# Googple maps API KEY
register_google(key = "[PUT YOUR API KEY HERE!!]") # Create your own key as shown in the ggmap documentation: https://github.com/dkahle/ggmap
# WGS84 lat Long centroid location for your scene...
@rveciana
rveciana / .block
Last active February 9, 2022 09:43
Svelte mapping: circles
licence: mit
@hrbrmstr
hrbrmstr / phantomjs.R
Created December 29, 2014 15:29
Scraping gnarly sites with phantomjs & rvest
library(rvest)
# example of using phantomjs for scraping sites that use a twisty maze
# of javascript to render HTML tables or other tags
# grab phantomjs binaries from here: http://phantomjs.org/
# and stick it somehere PATH will find it
# this example scrapes the user table from:
# Converting coordinates from DMS or DdM formats to decimal
# DMS = "degrees minutes seconds"; DdM = "degrees decimal minutes"
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dg2dec <- function(varb, Dg=NA, Min=NA, Sec=NA, SW.Hemisphere="S|W") {
# Dg=decimal, Min=minutes and Sec=seconds;
# NOTE 1 - if the format is "degrees decimal minutes - DdM" (e.g. 40° 26.767′ N) and not
# "degrees minutes seconds - DMS" (e.g. 40° 26′ 46″ N), then call the function only with
# Dg and Min arguments, like dg2dec(varb, Dg="°", Min="′N").
# Same applies when there is no seconds symbol (e.g. 45°12'7.38).
# Note that one should not use blank spaces in Dg, Min or Sec arguments (will return NA).
@dumbledore
dumbledore / mount-bitlocker
Created February 20, 2018 21:05
Mount/umount wrapper for dislocker on MacOS
#!/bin/bash
BITLOCKER_PARTITION="${1}"
BITLOCKER_PASSWORD="${2}"
function usage() {
echo "$(basename ${0}) <partition> <password>"
echo "Unlocks and mounts a bitlocker partition as read-only"
}
if [ -z "${BITLOCKER_PARTITION}" ]