Skip to content

Instantly share code, notes, and snippets.

View threesquared's full-sized avatar
👻

Ben Speakman threesquared

👻
View GitHub Profile

The new PostgreSQL 14.4 release fixes an issue with all versions of PostgreSQL 14 that can lead to silent corruption of indexes. You can find out if any indexes are affected with pg_amcheck:

CREATE EXTENSION amcheck;
GRANT EXECUTE ON FUNCTION verify_heapam(relation regclass, on_error_stop boolean, check_toast boolean, skip text, startblock bigint, endblock bigint, blkno OUT bigint, offnum OUT integer, attnum OUT integer, msg OUT text) TO root;
GRANT EXECUTE ON FUNCTION bt_index_check(regclass) TO root;
GRANT EXECUTE ON FUNCTION bt_index_check(regclass, boolean) TO root;
@threesquared
threesquared / ultimate-backup.sh
Created March 1, 2019 10:52
Ultimate Projects Backup Command
tar --exclude 'node_modules' --exclude '.git' --exclude 'vendor' --exclude '.sass-cache' --exclude '.idea' --exclude 'coverage' --exclude 'cache' --exclude 'bower_components' --exclude 'Pods' --exclude '.gradle' --exclude 'zip-cache' --exclude '.webpack' --exclude 'venv' --exclude 'external-modules' --exclude '.terraform' -vczf projects.tar *
@threesquared
threesquared / 01-custom
Created January 7, 2019 09:33
Custom MOTD Script
#!/bin/sh
# Save file as /etc/update-motd.d/01-custom and make executable. Requires figlet.
export TERM=xterm-256color
read one five fifteen rest < /proc/loadavg
echo "$(tput setaf 2)
`figlet -f graffiti "d-formed" | sed 's/^/ /'`
$(tput setaf 7)
@threesquared
threesquared / sni-verifiy.md
Created October 24, 2018 10:03
Validate SSL SNI certificate settings from the command line
echo | openssl s_client -showcerts -servername sni-domain.com -connect webserver.com:443 2>/dev/null | openssl x509 -inform pem -noout -text | grep "Subject:"
@threesquared
threesquared / intune.md
Created September 11, 2018 15:12
Disable Microsoft Intune password policy on MacOS

Microsoft Intune can enforce some pretty crazy password policies. Fortunately if you have root access you can disable the policy and reset your password to whatever you want with the following command:

$ sudo pwpolicy clearaccountpolicies

Then you can change your password as normal with:

<?php
namespace App\Services;
use Aws\Credentials\CredentialProvider;
use Aws\Credentials\Credentials;
use Aws\ElasticsearchService\ElasticsearchPhpHandler;
use Elasticsearch\ClientBuilder;
use Laravel\Scout\Engines\ElasticsearchEngine;

Keybase proof

I hereby claim:

  • I am threesquared on github.
  • I am threesquared (https://keybase.io/threesquared) on keybase.
  • I have a public key whose fingerprint is F03A 0EC2 55E1 E2C7 559A 0D1C 1A1B DA44 EA86 0CA7

To claim this, I am signing this object:

@threesquared
threesquared / gist:7564887
Created November 20, 2013 15:19
Grow a lat lon geobox based on a given radius in kilometres and a centre point
function point_distance($coords, $center)
{
$radius = 6378100; // radius of earth in meters
$latDist = $center[0] - $coords[0];
$lngDist = $center[1] - $coords[1];
$latDistRad = deg2rad($latDist);
$lngDistRad = deg2rad($lngDist);
$sinLatD = sin($latDistRad);
$sinLngD = sin($lngDistRad);
$cosLat1 = cos(deg2rad($center[0]));