Skip to content

Instantly share code, notes, and snippets.

View mplewis's full-sized avatar
🐕
柴犬

Matt Lewis mplewis

🐕
柴犬
View GitHub Profile
@mplewis
mplewis / LICENSE.md
Last active June 3, 2022 02:55
git blame with colored authors and pygments syntax highlighting. Dependencies: `pip install pygments tabulate colored`. License: MIT

The MIT License (MIT)

Copyright © 2021 Matt Lewis

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFT

@mplewis
mplewis / watchdiff.py
Last active April 30, 2022 22:32
Watch a single file and output a diff when it changes.
#!/usr/bin/env python3
from diff_match_patch import diff_match_patch
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
import sys
import time
from os.path import abspath, dirname
@mplewis
mplewis / google_latitude_api_access.py
Created July 14, 2013 03:54
A script that downloads your Google Latitude data and saves it into separate JSON files. Check out my blog post on this: http://www.mplewis.com/octopress/blog/2013/07/13/downloading-your-google-location-history-with-the-google-api-python-client-library/
#!/usr/bin/python
import httplib2
import json
from apiclient.discovery import build
from oauth2client.file import Storage
from oauth2client.client import AccessTokenRefreshError
from oauth2client.client import OAuth2WebServerFlow
from oauth2client.tools import run
from datetime import datetime
@mplewis
mplewis / tufte-css-automatic-sidenotes.js
Created November 3, 2015 05:51
Automatically add inline superscript reference numbers to your Tufte sidenotes.
// Add this to a <script> tag at the end of your <body>.
// Then, to add a sidenote, simply add the <span class="sidenote">
// and this script will add the <label> and <input> you need.
var sidenotes = document.querySelectorAll('span.sidenote')
for (var i = 0; i < sidenotes.length; i++) {
var sidenote = sidenotes[i]
var parent = sidenote.parentNode
var previous = sidenote.previousSibling
@mplewis
mplewis / aoc-2019-day-1.ts
Created December 6, 2019 21:09
Advent of Code stuff
const input = `
106404
140515
142745
120767
79665
54235
127391
72207
70799

How to Run a Fargate Task from AWS CLI

AWS_PROFILE=mplewis \
AWS_DEFAULT_REGION=us-west-1 \
aws ecs run-task \
  --launch-type FARGATE \
  --task-definition http-hello-world \
  --network-configuration '<CONFIG>'
  --overrides '<OVERRIDES>'
@mplewis
mplewis / iam_sam_policy.json
Created April 5, 2019 16:30
Perms needed to successfully deploy a Lambda via AWS SAM
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"cloudformation:*",
"iam:CreateRole",
"iam:AttachRolePolicy"
@mplewis
mplewis / ceto.rb
Created March 22, 2019 03:26
inspect a docker image's commands without having its dockerfile
#!/usr/bin/env ruby
# ceto
# from cetology: the scientific study of whales
# inspect a docker image's commands without having its dockerfile
# bash scripting stuff that probably needs to be broken up for visibility
SPECIALS = %w(
$\(
\)
/**
* @license
REI-Gearmail 0.1.0 2013-06-03 14:10 */
'use strict';
if ("undefined" == typeof console) {
window.console = {
log : function() {
},
error : function() {
}
@mplewis
mplewis / rockies_bot.py
Last active August 15, 2018 19:14
Drop a message in Slack when the Rockies have a home game.
#!/usr/bin/python3.5
import json
import arrow
from random import choice
from urllib.request import urlopen, Request
from sys import argv
from datetime import timedelta