Skip to content

Instantly share code, notes, and snippets.

View mikesprague's full-sized avatar

Michael Sprague mikesprague

  • Cornell University
  • New York
  • 02:14 (UTC -04:00)
View GitHub Profile
@mikesprague
mikesprague / install-docker-on-raspberry-pi.sh
Created March 18, 2018 13:10
Install and configure Docker for the Raspberry Pi
# get/start the offical docker installer
curl -sSL https://get.docker.com | sh
# set docker to auto-start
sudo systemctl enable docker
# start the docker daemon
sudo systemctl start docker
# enable docker client
@mikesprague
mikesprague / localweather.io-20180819T153541.json
Created August 19, 2018 19:42
localweather.io - Google Lighthouse Audits - August 19, 2018 15:35
{
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.42 Safari/537.36",
"lighthouseVersion": "3.0.3",
"fetchTime": "2018-08-19T19:35:41.503Z",
"requestedUrl": "https://localweather.io/",
"finalUrl": "https://localweather.io/",
"runWarnings": [],
"audits": {
"is-on-https": {
"id": "is-on-https",
@mikesprague
mikesprague / rollbar_deploy_notification.sh
Created September 3, 2018 20:46
Rollbar deploy notification (replace access token and rollbar user with your own values)
#!/bin/bash
ACCESS_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ENVIRONMENT=production
REVISION=`git log -n 1 --pretty=format:"%H"`
COMMENT=`cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g'`
ROLLBAR_USER=xxxxxxxxxx
curl https://api.rollbar.com/api/1/deploy/ \
-F access_token=$ACCESS_TOKEN \
@mikesprague
mikesprague / index.html
Created September 16, 2018 11:47
JS to lighten, darken, or blend colors (credit to/original author: https://glitch.com/@notwaldorf)
<!DOCTYPE html>
<html lang="en">
<head>
<title>Color gradient</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=IBM+Plex+Mono:400,700" rel="stylesheet">
<link rel="stylesheet" href="/style.css">
<script src="/script.js" defer></script>
*, html, html *, body, body * {
-webkit-font-smoothing: antialiased !important;
-moz-osx-font-smoothing: grayscale !important;
text-rendering: geometricPrecision !important;
}
body {
word-spacing: -1px;
-webkit-font-smoothing: auto;
}
@mikesprague
mikesprague / get-current-wordle.js
Last active October 14, 2022 14:49
Use Playwright to get the current Wordle solution
import puppeteer from 'puppeteer'
const wordleUrl = 'https://www.nytimes.com/games/wordle/index.html';
const wordleLocalStorageKey = 'nyt-wordle-state';
const defaultTimezone = 'America/New_York';
(async () => {
const browser = await puppeteer.launch({
args: [
'--no-sandbox',
@mikesprague
mikesprague / scratch.js
Created April 20, 2022 19:31
Scratch file I use when experimenting with Node.js code
const { hrtime } = process;
(async () => {
const debugStartTime = hrtime();
// do stuff
const debugEndTime = hrtime(debugStartTime);
console.log(
`Execution time: ${debugEndTime[0] * 1000 + debugEndTime[1] / 1000000}ms`,
@mikesprague
mikesprague / conventional-commits.md
Created November 27, 2022 12:42 — forked from Zekfad/conventional-commits.md
Conventional Commits Cheatsheet

Quick examples

  • feat: new feature
  • fix(scope): bug in scope
  • feat!: breaking change / feat(scope)!: rework API
  • chore(deps): update dependencies

Commit types

  • build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
  • ci: Changes to CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
  • chore: Changes which doesn't change source code or tests e.g. changes to the build process, auxiliary tools, libraries
@mikesprague
mikesprague / weatherkit-condition-codes.ts
Last active May 22, 2025 04:00
WeatherKit condition codes
// WeatherKit REST API documentation lists `conditionCode` as a property returned for
// various DataSets and says it's an enumeration value
// (e.g. https://developer.apple.com/documentation/weatherkitrestapi/currentweather/currentweatherdata)
// but never says what the possible return values could be anywhere in the REST API docs
//
// The following was created from info in the Swift documentation: https://developer.apple.com/documentation/weatherkit/weathercondition
export interface ConditionCode {
code: string;
description: string;
@mikesprague
mikesprague / chatgpt-text-to-emojis.js
Last active April 24, 2023 14:49
Using OpenAI to analyze text and return relevant emojis
import { Configuration, OpenAIApi } from 'openai';
import dotenv from 'dotenv';
import { gptGetEmoji } from './helpers.js';
dotenv.config();
const { OPEN_AI_API_KEY } = process.env;
const configuration = new Configuration({