This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Wrap a block of text to a given width | |
* via http://bl.ocks.org/mbostock/7555321 | |
*/ | |
var wrapText = function(texts, width, lineHeight) { | |
texts.each(function() { | |
var text = d3.select(this); | |
var words = text.text().split(/\s+/).reverse(); | |
var word = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d3.json( | |
"data/statistics.geojson", | |
function (json) { | |
//dimensions | |
var w = 980; | |
var h = 480; | |
//get the center of the data | |
var center = d3.geo.centroid(json); | |
var svg = d3.select("body").append("svg") | |
.attr("width", w) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# set max file size to include (in MB) | |
max_size_mb=100 | |
max_size_b="$(($max_size_mb * 1000000))c" | |
git_dir="$(git rev-parse --show-toplevel)" | |
git_exclude=$git_dir/.git/info/exclude | |
files="$(find $git_dir -path $git_dir/.git -prune -o -type f -size +$max_size_b -print | sed "s%$git_dir/%%g" | sed "s/\ /\\\ /g")" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | |
blue=$(tput setaf 4) | |
green=$(tput setaf 2) | |
normal=$(tput sgr0) | |
while ./update.sh | |
do | |
printf "\n${blue}>>> sleeping a little bit before running again... ${normal}\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env osascript -l JavaScript | |
// usage: google-earth-perspective-to-geojson.js xSamples ySamples > currentPerspective.geojson | |
function run(argv) { | |
var xSamples = argv[0] || 50; | |
var ySamples = argv[1] || 50; | |
var ge = Application('Google Earth Pro'); |
OlderNewer