Skip to content

Instantly share code, notes, and snippets.

View MatthewCallis's full-sized avatar
🍖
Hungry Goriya

Matthew Callis MatthewCallis

🍖
Hungry Goriya
View GitHub Profile
@MatthewCallis
MatthewCallis / input-filter.js
Created February 11, 2022 06:00
HTML Form Input Filtering
/**
* Check keyed input for semver values with onKeyPress.
*
* @param {React.KeyboardEvent} e Event
*/
export const versionOnly = (e) => {
const code = e.which || e.keyCode || 0;
// Allow: Backspace, Delete, Tab, Escape, Enter, Return
if ([46, 8, 9, 27, 13, 110].includes(code)) { return; }
// Allow: Decimals
@MatthewCallis
MatthewCallis / heart-snow.js
Created February 11, 2022 00:33
Konami Code Heart Snow Background
// Create the CSS
const styleText = document.createTextNode(`@keyframes snow {
0% { background-position: 0px 0px, 0px 0px, 0px 0px }
100% { background-position: 500px 1000px, 400px 400px, 300px 300px; }
}
body.heart-snow {
background-image:
url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAMAAABOo35HAAAAclBMVEX////fJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjffJjepqKlSAAAAJnRSTlMAKlhkSAoLUTtaTAQ8VkYUFWFgKxAdZjEWSVcGCCA5XENEAwUfMq8Mq3MAAAGmSURBVHgB7MGDFcBAFATAjW3b/beYEv49BzsDIiIiei1NN0wLpMJ2XM3zIaMgjOIEaQYZhXkRemWVQ0Z1A7RJZ4JkZl8NGOsJJBtmfVm3ZYcKOs7Vu+727tAKgBAGoiD9V41cH/PNTAUI4L3sJccDAAC5lFxKLiWXkkshl5JLyaUAQE2sJlYTq4nVxKiJ1cRq4gEAAAAAAAAArXNa57TOaZ3TOqd1Dq1zWucAAADJoeRQcig5lBwiOZQcSg4BAJAvyZfkS/Il5EvyJfmSfAkAABEVIioRlYhKRCWiElEhogIlAUoCJYGS4HBdKAl2XSgJLteFkuB+XSgJJAgSBNeFBAEAAAAAAAAA9Pxa9Zr4dCo3TXyHHRKsOmjiC3bIVt038SX7Olh10MQX7Outum/ii/Z1sOqgiS/Y11u15lTsEAAAAAAAAAAAAAAAAAAAAPDPLbyz653dnQfv7J
@MatthewCallis
MatthewCallis / toc.js
Created January 5, 2022 00:51
Table of Contents Generator
const tableOfContents = (options) => {
if (!options.element) {
return;
}
const container = options.container ? document.querySelector(options.container) : document.body;
const selectors = options.selectors ? options.selectors.split(',').map((s) => s.trim()) : ['h2', 'h3'];
const tocItems = [];
// Building dict
@MatthewCallis
MatthewCallis / docker-compose.yml
Created December 22, 2021 01:28
WordPress Docker
version: "3"
services:
# MySQL Database Image
mysql_database:
platform: linux/x86_64 # Required for Apple M1 chip
image: mysql
restart: unless-stopped
env_file: .env
environment:
@MatthewCallis
MatthewCallis / README.md
Created November 5, 2021 01:22
Simple Local WordPress
  1. Install Docker
  2. Create the docker-compose.yml in the empty directory we want to run the blog from
  3. Run docker-compose up -d from the directory we saved the docker-compose.yml
  4. Wait for everything to install and start
  5. Ensure any additional configuration you have in your production WordPress is in your wp-config.php file, but not the database credentials
  6. Replace the installed WordPress wp-content with your own
  7. Ensure your WordPress database is synced with production, phpMyAdmin is installed on http://localhost:8080
  8. You should now have a working local copy of your blog at http://localhost:8000

Instructions modified from Containerizing WordPress with Docker-Compose

@MatthewCallis
MatthewCallis / .eslintrc
Created May 1, 2021 19:43
ESLint Setup
{
"extends": [
"airbnb",
"plugin:ava/recommended",
"plugin:jsdoc/recommended",
"plugin:node/recommended",
"plugin:optimize-regex/all",
"plugin:ramda/recommended",
"plugin:security/recommended",
"plugin:unicorn/recommended"
@MatthewCallis
MatthewCallis / jest-helpers-api.js
Last active August 16, 2023 17:03
Jest Testing Helpers for React Components with Promises
import fetch from 'isomorphic-fetch';
expost const get = async (url, headers = {}) => fetch(url, {
method: 'GET',
headers: {
Accept: 'application/json',
...headers,
},
});
@MatthewCallis
MatthewCallis / country-codes.json
Created March 9, 2021 01:00
Country Codes & Locale Language Codes as JSON
[
{ "title": "Andorra", "value": "AD" },
{ "title": "United Arab Emirates", "value": "AE" },
{ "title": "Afghanistan", "value": "AF" },
{ "title": "Antigua and Barbuda", "value": "AG" },
{ "title": "Anguilla", "value": "AI" },
{ "title": "Albania", "value": "AL" },
{ "title": "Armenia", "value": "AM" },
{ "title": "Angola", "value": "AO" },
{ "title": "Antarctica", "value": "AQ" },
@MatthewCallis
MatthewCallis / deadlines-summary.md
Created February 16, 2021 22:41
This is a summary of a Clubhouse conversation between several people, but predominantly @shl from Gumroad and @jasonfried from Basecamp.
@MatthewCallis
MatthewCallis / flash.md
Last active December 3, 2023 22:58
Disable Flash EOL Warnings
Disable EOL uninstall warnings:
	Disable auto updates when installing
	Add "EOLUninstallDisable=1" to mmc.cfg in C:\WINDOWS\system32\Macromed\Flash
	(C:\Windows\SysWOW64\Macromed\Flash on 64-bit)

---

Defuse flash player time bomb: