Skip to content

Instantly share code, notes, and snippets.

@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
@dannguyen
dannguyen / congress-twitter-data-getter.md
Last active August 21, 2022 07:57
Who Congress Follows on Twitter data

Find out who Congress follows on Twitter using the command line

Part of a lesson for the Stanford Journalism Computational Methods in the Civic Sphere

This is a short tutorial on how to use command-line tools, including csvfix and t, the command-line Twitter interface, to access and parse data from the Sunlight Foundation and Twitter. The end goal of this exercise is to gather who everyone in Congress follows (friends, in the parlance of Twitter), and then count up the common friends to find out which Twitter accounts are most followed by members of Congress.

Here's a screenshot of the result, after it's been imported into [Google Spreadsheets](https://docs.google.com/spreadsheets/d/1cjRJyrPYj8KAhUrot8ubPOWgbAwm0OqIgPtsswJ2sjM/edit#gid=1358907576

@Rich-Harris
Rich-Harris / service-workers.md
Last active April 21, 2024 16:24
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@gka
gka / multi-crowbar.js
Last active April 29, 2021 21:44
like svg-crowbar, but for multiple svg elements!
var multiCrowbar = (function() {
/*
* SVG Export
* converts html labels to svg text nodes
* will produce incorrect results when used with multi-line html texts
*
* Author: Gregor Aisch
* based on https://github.com/NYTimes/svg-crowbar/blob/gh-pages/svg-crowbar-2.js
*/
@nvictus
nvictus / loadnpy.js
Last active November 4, 2023 18:47
NumPy binary file parser for javascript
// Client-side parser for .npy files
// See the specification: http://docs.scipy.org/doc/numpy-dev/neps/npy-format.html
var NumpyLoader = (function () {
function asciiDecode(buf) {
return String.fromCharCode.apply(null, new Uint8Array(buf));
}
function readUint16LE(buffer) {
var view = new DataView(buffer);
var val = view.getUint8(0);
module.exports = {
server: '.',
files: [
'*.html',
'src/*'
],
ui: false,
notify: false
};
# data from http://ec.europa.eu/eurostat/web/gisco/geodata/reference-data/population-distribution-demography/geostat
# Originally seen at http://spatial.ly/2014/08/population-lines/
# So, this blew up on both Reddit and Twitter. Two bugs fixed (southern Spain was a mess,
# and some countries where missing -- measure twice, submit once, damnit), and two silly superflous lines removed after
# @hadleywickham pointed that out. Also, switched from geom_segment to geom_line.
# The result of the code below can be seen at http://imgur.com/ob8c8ph
library(tidyverse)
@ramnathv
ramnathv / concaveman.R
Created May 2, 2017 03:58
Using Concaveman in R using V8
# Using concaveman in R using V8
concaveman <- function(d){
library(V8)
ctx <- v8()
ctx$source('https://www.mapbox.com/bites/00222/concaveman-bundle.js')
jscode <- sprintf(
"var points = %s;var polygon = concaveman(points);",
jsonlite::toJSON(d, dataframe = 'values')
)
ctx$eval(jscode)
const regl = require('regl')({
extensions: 'OES_texture_float'
})
const LAPLACIAN_SHADER = `
vec4 laplacian (sampler2D img, vec2 id, float DX) {
return -texture2D(img, id) + 0.25 * (
texture2D(img, id + DX * vec2(-1, 0))
+ texture2D(img, id + DX * vec2(1, 0))
+ texture2D(img, id + DX * vec2(0, -1))