Skip to content

Instantly share code, notes, and snippets.

View bcks's full-sized avatar

John Emerson bcks

View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Calendar of Police Killings</title>
<link href="https://fonts.googleapis.com/css2?family=Fira+Sans:ital,wght@0,400;0,700;1,400&display=swap" rel="stylesheet">
<style>
body { font-family: 'Fira Sans'; text-align: center; }
@bcks
bcks / htmldiff.js
Created January 31, 2021 14:57
htmldiff
(function() {
var Match, calculate_operations, consecutive_where, create_index, diff, find_match, find_matching_blocks, html_to_tokens, is_end_of_tag, is_start_of_tag, is_tag, is_whitespace, isnt_tag, op_map, recursively_find_matching_blocks, render_operations, wrap;
is_end_of_tag = function(char) {
return char === '>';
};
is_start_of_tag = function(char) {
return char === '<';
};
@bcks
bcks / nyt-banner-headlines.csv
Created January 6, 2021 21:13
A list of every banner headline appearing in The New York Times from its founding through the end of 2020. Collected for the visualization project https://backspace.com/bignews
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
Date
1912-04-16
1912-04-17
1912-04-18
1912-04-19
1912-07-03
1912-10-15
1914-04-22
1914-04-24
1914-04-25
@bcks
bcks / scrpt
Created June 27, 2020 17:11
Use AppleScript to export all open Safari Tabs into a BBEdit list
(*
Make a BBEdit list of all open Safari tabs
Adapted by John Emerson, https://backspace.com
from Jesse Squires, https://www.jessesquires.com
who adapted it from http://veritrope.com/code/safari-tab-list-to-omnifocus/
*)
global allItems
set allItems to {}
@bcks
bcks / index.js
Last active November 27, 2020 07:36
tableau-covid-scraping
// Works with Node v12.0 and puppeteer 4.0
const URL = 'https://public.tableau.com/views/PPV_15924847800480/ppv_db?%3Aembed=y&%3AshowVizHome=no&%3Adisplay_count=y&%3Adisplay_static_image=n&%3AbootstrapWhenNotified=true&%3Alanguage=en&:embed=y&:showVizHome=n&:apiID=host0';
const puppeteer = require('puppeteer');
function parseDataDictionary(jsonParsed) {
@bcks
bcks / #30DayMapChallenge.csv
Created November 30, 2019 18:37
Tweets from the #30DayMapChallenge, 2019
We can't make this file beautiful and searchable because it's too large.
id,conversation_id,created_at,date,time,timezone,user_id,username,name,place,tweet,mentions,urls,photos,replies_count,retweets_count,likes_count,hashtags,cashtags,link,retweet,quote_url,video,near,geo,source,user_rt_id,user_rt,retweet_id,reply_to,retweet_date
1200809611835707392,1192855827272675329,1575130296000,2019-11-30,11:11:36,EST,1192848641771393027,colmixe,Colmix,,"Día 30: Hogar / Tëk'äm
¿Y cómo no pensar en el territorio y las comunidades mixes sin pensar en la música?
El título de la obra musical es el título del mapa ¿Sabes cuál es?
#30daymapchallenge pic.twitter.com/RoiBym0ahe",[],[],['https://pbs.twimg.com/media/EKoh5_fWwAUNXMl.jpg'],0,0,0,['#30daymapchallenge'],[],https://twitter.com/Colmixe/status/1200809611835707392,False,,0,,,,,,,"[{'user_id': '1192848641771393027', 'username': 'Colmixe'}]",
1200807377500545024,1200807377500545024,1575129763000,2019-11-30,11:02:43,EST,2198358416,tjukanov,Topi Tjukanov,,"If I would like to do some analysis and collect basic statistics for the #30DayMapChalle
@bcks
bcks / gist:6f3c16ee0cec701c10ce67b104865517
Last active January 18, 2018 13:44
Make an image of text
// a node.js method for creating images of text
// as used in https://twitter.com/nytanon and https://twitter.com/wapoanon
function makeImage(object, que, callback) {
var text = object.text;
var Canvas = require('canvas'),
Image = Canvas.Image,
canvas = new Canvas(200, 200),
@bcks
bcks / catalogbot.js
Last active July 6, 2017 13:59
Cooper Hewitt Catalog Bot
var fs = require('fs'),
PDFDocument = require('pdfkit'),
async = require('async'),
ColorThief = require('color-thief'),
colorThief = new ColorThief();
var bookWidth = 430;
var bookHeight = 343;
@bcks
bcks / fisabot.js
Created October 7, 2015 19:57
FISAbot is a bot for expedited processing of FISA warrant requests via Twitter. Not officially affiliated with the US Foreign Intelligence Surveillance Court.
var Twitter = require('node-twitter');
function getVerdict() {
// http://en.wikipedia.org/wiki/United_States_Foreign_Intelligence_Surveillance_Court
var caseNumber = Math.floor(Math.random() * 33942) + 1;
if (caseNumber <= 11) { return 'Application denied. Please submit appeal to the Court of Review.'; }
else if ((caseNumber > 11) && (caseNumber <= 504 + 515)) { return 'Please modify your request and resubmit.'; }
else { return 'I authorize this request.'; }
}
@bcks
bcks / brookyln_museum.js
Last active August 29, 2015 14:05
Brooklyn Museum Bot
// runs under Node.js
var fs = require('fs'),
request = require('request'),
Twitter = require('node-twitter');
var twitterRestClient = new Twitter.RestClient(
'CONSUMER_KEY',
'CONSUMER_SECRET',
'TOKEN',