Skip to content

Instantly share code, notes, and snippets.

View petulla's full-sized avatar

Sam Petulla petulla

View GitHub Profile
@noahlt
noahlt / killport.sh
Last active September 15, 2017 16:25
killport - kill whatever process is running on a given port
# add this to your .bash_profile to use it
# source: https://gist.github.com/noahlt/2662634
function killport {
if [ ! -n "$1" ] || [ $1 == '--help' ] || [ $1 == '-h' ]
then
echo '`killport <PORT>` finds the process listening to the specified port and kills it.'
else
process_line=`sudo lsof -i :$1 | tail -1`
if [ "$process_line" == "" ]
then
@mbostock
mbostock / .block
Last active March 29, 2023 00:13
Lab and HCL Color Spaces
license: gpl-3.0
@JDWarner
JDWarner / _jaccard.py
Last active April 20, 2024 01:38
Jaccard coefficient between two boolean NumPy arrays or array-like data. This is commonly used as a set similarity metric, and it is a true metric. The dimensionality of the input is completely arbitrary, but `im1.shape` and `im2.shape` much be equal. This Gist is licensed under the modified BSD license, otherwise known as the 3-clause BSD.
"""
_jaccard.py : Jaccard metric for comparing set similarity.
"""
import numpy as np
def jaccard(im1, im2):
"""
-- Census tract population is column dp0010001
WITH op AS
(SELECT the_geom,
cartodb_id,
dp0010001,
Row_number() OVER (
ORDER BY Cdb_latlng(/* Starting latitude */, /* Starting longitude */) <-> the_geom) AS row_number
FROM /* Table name */ LIMIT /* Max census tracts queryable */),
sm AS
@dwtkns
dwtkns / l8get
Last active October 1, 2017 20:19
A shell function to quickly grab the data for a given Landsat 8 tile ID from Google's servers
# This is a shell function to quickly grab the data for a given Landsat 8 tile ID from Google's servers
# For example:
# l8get LC81690352014169LGN00
# The echo at the end is to remind myself of the syntax for extracting bands 8, 4, 3, and 2. (Pansharp, Red, Green, Blue)
# On OSX this would go into your ~/.bash_profile file.
# Requires gsutil from https://developers.google.com/storage/docs/gsutil_install
# Most useful in conjunction with USGS' Earth Explorer: http://earthexplorer.usgs.gov/
@dannguyen
dannguyen / nyt-list-scrape.rb
Last active August 29, 2015 14:04
A script to scrape what nytimes.com recommends to me and also, what is popular among other users
#!/usr/bin/env ruby
# nyt-list-scrape.rb
# Dan Nguyen @dancow
# Created: 2014-07-26
# Updated: 2014-07-29
#
# Scrape the titles/urls of articles recommended to the user by the NYT,
# and also, the most popular ones at the moment
#
# Requirements: Ruby 1.9.x and the Mechanize gem and a NYT digital subscriber account
@briantjacobs
briantjacobs / storytelling_from_space.md
Last active February 18, 2024 10:02
Storytelling from Space

Storytelling from Space: Tools/Resources

This list of resources is all about acquring and processing aerial imagery. It's generally broken up in three ways: how to go about this in Photoshop/GIMP, using command-line tools, or in GIS software, depending what's most comfortable to you. Often these tools can be used in conjunction with each other.

Acquiring Landsat & MODIS

Web Interface

  • Landsat archive
@dalekunce
dalekunce / mac_gis_setup.md
Last active July 29, 2023 22:18
Yosemite GIS Machine Setup

Mac OS X GIS Setup

OS X Preferences


# Expand save panel by default
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
FAQ:
where are some fun datasets to play with?
1. CMU:
http://lib.stat.cmu.edu/datasets/
2. UCI:
a) MLR@UCI (machine learning repository / machine learning archive )
@emeeks
emeeks / d3.svg.circularbrush.js
Last active March 29, 2016 19:39
Circular Brush 3
d3.svg.circularbrush = function() {
var _extent = [0,Math.PI * 2];
var _circularbrushDispatch = d3.dispatch('brushstart', 'brushend', 'brush');
var _arc = d3.svg.arc().innerRadius(50).outerRadius(100);
var _brushData = [
{startAngle: _extent[0], endAngle: _extent[1], class: "extent"},
{startAngle: _extent[0] - .2, endAngle: _extent[0], class: "resize e"},
{startAngle: _extent[1], endAngle: _extent[1] + .2, class: "resize w"}
];
var _newBrushData = [];