Skip to content

Instantly share code, notes, and snippets.

View chrislkeller's full-sized avatar

Chris Keller chrislkeller

View GitHub Profile
@chrislkeller
chrislkeller / import_json_appsscript.js
Last active July 16, 2024 13:26
Adds what amounts to an =ImportJSON() function to a Google spreadsheet... To use go to Tools --> Script Editor and add the script and save.
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@chrislkeller
chrislkeller / senate_intelligence_commitee_members_2001_2018.csv
Last active January 2, 2024 23:06
A rundown of members of the U.S. Senate Intelligence Committee between 2001 and the current session though 2018. Data acquired from the Senate Intelligence Committee webpages. Includes member ID and link to bio page on ProPublica's Represent news app
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 10 columns, instead of 9. in line 5.
order_id,congress,years,senator,member_id,party,state,notes,source,pro_publica_represent
51,115th Congress,2017-2018,Angus King,K000383,Democrat,Maine,,https://www.intelligence.senate.gov/about/committee-members-115th-congress-2017-2018,https://projects.propublica.org/represent/members/K000383
71,114th Congress,2015-2016,Angus King,K000383,Democrat,Maine,,https://www.intelligence.senate.gov/about/committee-members-114th-congress-2015-2029,https://projects.propublica.org/represent/members/K000383
91,113th Congress,2013-2014,Angus King,K000383,Democrat,Maine,,https://www.intelligence.senate.gov/about/committee-members-113th-congress-2013-2014,https://projects.propublica.org/represent/members/K000383
17,107th Congress,2001-2002,Barbara A. Mikulski,M000702,Democrat,Maryland,,https://www.intelligence.senate.gov/about/committee-members-107th-congress-2001-2002,https://projects.propublica.org/represent/members/M000702
36,108th Congress,2003-2004,Barbara A. Mikulski,M000702,Democrat,Maryland,,https://www.intelligence
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chrislkeller
chrislkeller / README.md
Last active January 27, 2023 16:26
Convert string Lat/Long to number for Google Maps API.

Convert string Lat/Long to number for Google Maps API

When sending Lat/Long values to the Google Maps API for something like setCenter(), it wants an number value. But the value we pull from an option menu like the one below is a string.

<select id="searchString" onchange="zoomToAddress(this.value);">
<option value="">--Select All--</option>
<option value="43.138092,-89.747988">Luckenbooth Cafe</option>
<option value="43.017218,-89.831479">Aunt Mary's Hooterville Inn</option>
</select>
@chrislkeller
chrislkeller / README.md
Last active December 16, 2022 15:25
Sync data across Google Spreadsheets

Snippets: Sync data across Google Spreadsheets

Added to a Google spreadsheet, this script will take data from a master spreadsheet and sync it to a working spreadsheet.

Variables to change are:

// source doc
var sss = SpreadsheetApp.openById('0An8....');

// source sheet

@chrislkeller
chrislkeller / blogpost.md
Last active October 5, 2022 15:09
A quick Python script that implements "paging" -- or at least Twitter's version of it -- to search the social media platform's API for a given hashtag

I helped the folks at #wjchat a while back by writing a quick django app to pull tweets each week and save them to a database. The tweets were then accessible as formatted HTML that could be posted in the #wjchat Wordpress blog.

But something happened around the middle of April. The script pulled in 389 tweets on April 16, but the following week only caught 100. Same for the week after.

I did some hand-holding for a few weeks, but more and more of the same occurred.

#wjchat-transcript news: @ChrisLKeller & I are aware we’re a couple weeks behind. Pipes running the transcripts are a little clogged. Soon!

— P. Kim Bui (@kimbui) June 20, 2014
[{"transcript":"two minutes and I don't know if doctors Graces back yet doesn't sound like it. Oh there he is awesome. Okay two minutes and then I'll start letting the reporters in and we'll have a bit of a delay um as they file in. I'm gonna let the reporters in now. Good afternoon and welcome to today's press conference. Thank you for joining us. My name is jodi Mcginnis Porter and I'll be moderated. Today's Covid 19 day 715 Press update. The press conference will last for about 45 minutes which includes a short presentation from doctors Grace and Q. And A. From our media partners. When we get to the Q. And a portion. If the reporter would please raise your hand if you'd like to ask a question and keep it raised We will lower it for you will go through one round of questions and if we have time we'll go to round two I'll turn it over now to dr Grace to go through his presentation. Good afternoon everybody. It's good to be back. Let me just changed my view. Perfect. And up I want to start today by introducin
@chrislkeller
chrislkeller / README.md
Last active February 3, 2022 08:02
Displaying data from a flat JSON file on a Handlebars.js template file rendered with AJAX.

Demo: ajax-handlebars

This repo's location has changed.

@chrislkeller
chrislkeller / compassbearing.py
Created August 31, 2021 21:34
Thanks Ryan Murphy for the addition to the toolkit
# LICENSE: public domain
def calculate_initial_compass_bearing(pointA, pointB):
"""
Calculates the bearing between two points.
The formulae used is the following:
θ = atan2(sin(Δlong).cos(lat2),
cos(lat1).sin(lat2) − sin(lat1).cos(lat2).cos(Δlong))
import smtplib
from email.message import EmailMessage
import csv
import logging
logger = logging.getLogger("root")
logging.basicConfig(
format="\033[1;36m%(levelname)s: %(filename)s (def %(funcName)s %(lineno)s): \033[1;37m %(message)s",
level=logging.DEBUG
)