Skip to content

Instantly share code, notes, and snippets.

@joemaller
joemaller / Managed WordPress Hosting .gitignore
Last active August 11, 2023 21:40
A comprehensive .gitignore file for managed WordPress hosts.
# Managed WordPress Hosting .gitignore file for ignoring WordPress files
#
# Most recent revision here:
# https://gist.github.com/joemaller/4f7518e0d04a82a3ca16
#
# Raw Source (for curl):
# https://gist.githubusercontent.com/joemaller/4f7518e0d04a82a3ca16/raw
#
# Used by these WordPress Development environments:
# https://github.com/ideasonpurpose/docker-wordpress-dev
@joemaller
joemaller / compressing-all-images-wordpress.md
Last active June 23, 2023 17:50
How to make sure all images uploaded to WordPress are optimized

Compressing All Uploaded Images with WordPress

A Not Unreasonable Assumption

A lot of WordPress users assume, rightly, that images they've uploaded are compressed and optimized for the web.

This assumption is mostly true, but sometimes poorly-compressed or oversized images will slip through. We can't expect every website user to know the intricasies of image compression, and it's not unreasonable to expect that WordPress should make all uploaded images work correctly.

So let's do that. Here's how to make sure every image uploaded to WordPress is optimized.

@joemaller
joemaller / wsl-port-proxy.json
Created March 3, 2023 20:08
script and config file for configuring WSL 2 portproxy rules
{
"ports": [3000, 5173, 8000]
}
@joemaller
joemaller / conversion.js
Created November 15, 2022 15:48
Question about preferred code conversion
// Starting with an API returned data structure like this:
const Parameters = [
{
Name: "PASS",
Type: "SecureString",
Value: "cGFzc3dvcmQ=",
Version: 3,
LastModifiedDate: "2022-11-14T15:13:08.263Z",
ARN: "arn:aws:ssm:us-east-1:678000000000:parameter/PASS",
@joemaller
joemaller / curl-format.txt
Created November 8, 2022 20:13
Template for reporting connection times from curl connections. More here: https://blog.josephscott.org/2011/10/14/timing-details-with-curl/
\n
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
———\n
time_total: %{time_total}\n
@joemaller
joemaller / case-conversion.md
Created September 23, 2022 20:30
Case Conversion examples

Input: my name is bond

Name Sample
🐪 Camel case myNameIsBond
👨‍🏫 Pascal case MyNameIsBond
🐍 Snake case my_name_is_bond
👩‍🏫 Ada case My_Name_Is_Bond
Ⓜ️ Macro case MY_NAME_IS_BOND
🥙 Kebab case my-name-is-bond
@joemaller
joemaller / luxon.md
Created January 23, 2018 14:29
Luxon Timestamps

Finding this took me longer than it should have, probably because I was impatiently looking for "timeststamp" instead of "milliseconds of the Unix epoch". For future searchers, Luxon uses the methods DateTime.fromMillis and DateTime.valueOf.

// Create a Luxon DateTime from a JS Unix timestamp
const ts = new Date().getTime();     // 1516717417146
const dt = DateTime.fromMillis(ts);  // { ts: 2018-01-23T09:23:37.146-05:00 ...
console.log(dt.valueOf());           // 1516717417146
@joemaller
joemaller / index.html
Last active September 9, 2022 16:28 — forked from d3noob/index.html
Add multiple markers in leaflet.js
<!DOCTYPE html>
<html>
<head>
<title>Simple Leaflet Map</title>
<meta charset="utf-8" />
<link
rel="stylesheet"
href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css"
/>
</head>
@joemaller
joemaller / child-filepath.md
Last active June 17, 2022 15:13
Get PHP child Class file paths from inherited parent class methods

Get PHP child Class file paths from inherited parent class methods

While refactoring some code into a reusable PHP Class I hit a brief roadblock where some code expected the [__FILE__ magic constant][file] file path. Since that value always refers to the specific file it's called from, it won't work from a separate Class file because the referenced path would be the parent instead of the child.

The full filepath of a child Class can be inferred from an inherited parent Class method by combining [get_class($this)][get_class] or [get_called_class()][get_called_class] with the [ReflectionClass::getFileName][getfilename] method like this:

// ParentClass.php
class ParentClass
{
@joemaller
joemaller / attributes.md
Last active February 6, 2022 17:15
Out of deference to Prettier, I'm switching to filling empty attributes

Previously, for "cleaner HTML" I tended to prefer something like this:

<?php 
$classes = ['cat', 'dog'];
$classAtt = empty($classes) ? "" : " class='" . implode($classes, ' ') . '"'; 
?>
<div<$= $classAtt ?>>Text</div>

That string concatenation is just gross, but the HTML is "nicer"; the opening tag will either be or.