Skip to content

Instantly share code, notes, and snippets.

View mikesprague's full-sized avatar

Michael Sprague mikesprague

View GitHub Profile
/* source: https://andy-bell.co.uk/a-more-modern-css-reset/ */
/* Box sizing rules */
*,
*::before,
*::after {
box-sizing: border-box;
}
/* Prevent font size inflation */
@mikesprague
mikesprague / run-updates.sh
Created May 25, 2023 16:28
Bash script to run some common updates/commands I use
#!/bin/bash
# PREREQUISITES:
# - Homebrew
# - Zsh
# - oh-my-zsh
# - Node.js with the following global packages installed:
# - npm-check-updates
# - n
# - Docker
@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({
@mikesprague
mikesprague / weatherkit-condition-codes.ts
Last active August 24, 2023 11:52
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 / 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 / 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 / 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',
*, 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 / 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>
@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 \