Skip to content

Instantly share code, notes, and snippets.

View jonathanstegall's full-sized avatar

Jonathan Stegall jonathanstegall

View GitHub Profile
@adactio
adactio / geocode.php
Created December 16, 2024 15:04
A PHP script that uses a third-party provider to get latitude, longitude, and zoom level (for use in embedded maps).
<?php
/*
Pass in a string: geocode("The Jolly Brewer, Brighton, East Sussex England")
The output is an array with keys for "latitude", "longitude", and "zoom".
*/
function geocode($location, $provider = "mapquest") {
$return = array();
@brianckeegan
brianckeegan / post_2024_news_sources.md
Last active November 8, 2024 08:10
Post-2024 news sources

Note

Going to move development to this repo to make PRs easier to manage: https://github.com/brianckeegan/Post_2024_News

Post-2024 news

Mainstream media failed to hold Trump to account over the course of the 2024 presidential campaign through "view from nowhere" centrism and false equivalencies between both campaigns.

Here is a list of news organizations, newsletters, and writers that are audience-funded and/or non-profits committed to independent and investigative journalism.

Rules

  • No centrist contrarians or right-wing authors
@dhh
dhh / linux-setup.sh
Last active September 7, 2025 22:38
linux-setup.sh
# THIS LINUX SETUP SCRIPT HAS MORPHED INTO A WHOLE PROJECT: HTTPS://OMAKUB.ORG
# PLEASE CHECKOUT THAT PROJECT INSTEAD OF THIS OUTDATED SETUP SCRIPT.
#
#
# Libraries and infrastructure
sudo apt update -y
sudo apt install -y \
docker.io docker-buildx \
build-essential pkg-config autoconf bison rustc cargo clang \
@adactio
adactio / redirect.php
Last active January 2, 2024 23:24
A proxy that tries to redirect bad links to the internet archive.
<?php
// Check that the request is coming from my site.
if (!isset($_SERVER['HTTP_REFERER']) || !stristr(strtolower($_SERVER['HTTP_REFERER']), strtolower($_SERVER['SERVER_NAME']))) {
http_response_code(403);
exit;
}
// There has to be a URL provided in the query string.
if (!isset($_GET['url'])) {
@adactio
adactio / redirectLinks.js
Last active November 20, 2023 18:11
Intercept clicks on external links and pass them to a redirector.
@adactio
adactio / autoLinkMastodonUsernames.php
Created October 30, 2023 13:11
A regular expression to convert @@ usernames into hyperlinks
<?php
/* Pass a string of text into the function to convert @@ usernames. */
function autoLinkMastodonUsernames($string) {
return preg_replace(
'/@?\b([A-Za-zŽžÀ-ÿ0-9._%+-]+)@([A-Za-zŽžÀ-ÿ0-9.-]+\.[A-Za-zŽžÀ-ÿ]{2,})\b/i',
'<a href="https://$2/@$1">$0</a>',
$string
@adactio
adactio / updateDateTimes.js
Last active September 11, 2023 05:10
Periodically update the text of `datetime` elements with the relative time elapsed.
(function (win, doc) {
'use strict';
if (!doc.querySelectorAll || !win.Intl || !win.Intl.RelativeTimeFormat) {
// doesn't cut the mustard.
return;
}
var rtf = new Intl.RelativeTimeFormat('en', {
localeMatcher: 'best fit',
numeric: 'always',
style: 'long'
@robweychert
robweychert / eleventy.config.js
Last active July 25, 2024 16:40
Custom collections in Eleventy based on your posts’ front matter
module.exports = function(eleventyConfig) {
// Make a custom collection based on a key in your posts' front matter
function addCollectionByKey(collectionName, postKey, paginate=true, postsPerPage=100) {
eleventyConfig.addCollection(collectionName, function(collectionApi) {
const collectionObjects = {};
let collectionFinal = [];

local installation of Elasticsearch for WordPress VIP Go infrastructure

Update, 11/2022:

Apparently none of this will work with Elasticsearch versions greater than 8.0. See elastic/homebrew-tap#126 (comment). The alternative seems to be to use Docker, or since it's a big system either way might as well switch to VVV.

Previous instructions

These are basic instructions, and I'm sure could be tightened up.

docs/*,vendor/*,release/*