Skip to content

Instantly share code, notes, and snippets.

Avatar

Marcus Bointon Synchro

View GitHub Profile
@Synchro
Synchro / sphp
Last active Jan 12, 2022 — forked from rozsival/sphp
Easy Brew PHP-FPM switch
View sphp
#!/usr/bin/env bash
latest="8.1"
versions=("7.4" "8.0" "$latest")
valid=$(printf "|%s" "${versions[@]}")
switch="$1"
ERROR=$(tput setaf 1)
SUCCESS=$(tput setaf 2)
if [ -z "$switch" ]
@Synchro
Synchro / gist:1139429
Created Aug 11, 2011
PHP Base-62 encoder/decoder
View gist:1139429
<?php
/**
* This is an example of a practical encoder and decoder for base-62 data in PHP
* It differs from the majority of examples in that it's fast enough for moderate data sizes, unlike multiprecision converters
* To be practical, base-62 encoding needs to use internal chunking and padding because base-62 does not fit exactly into any integral number of bits
* This means the output is not quite compatible with multiprecision conversions,
* but the encoded data retains all the desirable properties of base-62, so (unlike any base-64 encoding) it's URL, DNS, email address and pathname safe
* @author Marcus Bointon <marcus@synchromedia.co.uk>
* @copyright 2011 Marcus Bointon
* @license http://www.opensource.org/licenses/mit-license.html MIT License
@Synchro
Synchro / sfprefix.php
Created Jan 19, 2017
Salesforce prefix to entity name mapping
View sfprefix.php
<?php
/**
* Mapping array for salesforce ID prefixes to entity name & description.
* @link http://www.fishofprey.com/2011/09/obscure-salesforce-object-key-prefixes.html
* Convert copy/paste from that page with:
* Search: '^([a-zA-Z0-9]+)[ \t]+(\w+)[ \t]*(.*)$'
* Replace: ' '$1' => ['$2', '$3'],'
* @author Marcus Bointon <marcus@synchromedia.co.uk>
*/
@Synchro
Synchro / Premailer.php
Created Sep 8, 2011
PHP interface class for the Premailer API
View Premailer.php
<?php
/**
* Premailer API PHP class
* Premailer is a library/service for making HTML more palatable for various inept email clients, in particular GMail
* Primary function is to convert style tags into equivalent inline styles so styling can survive <head> tag removal
* Premailer is owned by Dialect Communications group
* @link http://premailer.dialect.ca/api
* @author Marcus Bointon <marcus@synchromedia.co.uk>
*/
@Synchro
Synchro / gist:3749394
Created Sep 19, 2012
PHP script to report and/or extract sections from apache and icecast log files by date ranges
View gist:3749394
#!/usr/bin/env php
<?php
/**
* Extract a section of an apache or icecast log file between two dates
* Assumes that log lines are in chronological order
* Start and end dates can be in any format that strtotime can handle
* Reads from stdin, outputs to stdout, stats to stderr
* @author Marcus Bointon <marcus@synchromedia.co.uk>
* @link https://gist.github.com/3749394
* Example usage. Report the range of dates in a log file
@Synchro
Synchro / add_apache_brew.md
Last active Jun 18, 2017 — forked from vitorbritto/add_apache_brew.md
Install Apache with Homebrew
View add_apache_brew.md

Install Apache with Homebrew

Installing Apache

# Start by stopping the built-in Apache, if it's running, and prevent it from starting on boot.
# This is one of very few times you'll need to use sudo:
sudo launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist 2> /dev/null

# Install Apache 2.4 with the event MPM and HTTP/2 support

brew install -v homebrew/apache/httpd24 --with-mpm-event --with-http2

@Synchro
Synchro / # hhvm - 2016-09-20_08-39-45.txt
Created Sep 20, 2016
hhvm (hhvm/hhvm/hhvm) on macOS 10.11.6 - Homebrew build logs
View # hhvm - 2016-09-20_08-39-45.txt
Homebrew build logs for hhvm/hhvm/hhvm on macOS 10.11.6
Build date: 2016-09-20 08:39:45
@Synchro
Synchro / hpkp-tlsa.sh
Last active Sep 12, 2016 — forked from aeris/hpkp-tlsa.sh
Generate HPKP or TLSA fingerprint
View hpkp-tlsa.sh
#!/bin/bash
# Uses pkey instead of rsa so it also works with ecc certs
case "$1" in
hpkp)
case "$2" in
key)
openssl pkey -in "$3" -outform der -pubout 2>/dev/null | openssl dgst -sha256 -binary | openssl enc -base64
;;
csr)
openssl req -in "$3" -pubkey -noout | openssl pkey -pubin -outform der 2>/dev/null | openssl dgst -sha256 -binary | openssl enc -base64
@Synchro
Synchro / better.fyi ssl info.md
Last active Aug 10, 2016
better.fyi cipher issue
View better.fyi ssl info.md

Chrome 54 cipher list (from https://www.ssllabs.com/ssltest/viewMyClient.html):

TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 (0xcca9)   Forward Secrecy	256
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (0xcca8)   Forward Secrecy	256
OLD_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 (0xcc14)   Forward Secrecy	256
OLD_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (0xcc13)   Forward Secrecy	256
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 (0xc02b)   Forward Secrecy	128
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (0xc02f)   Forward Secrecy	128
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 (0xc02c) Forward Secrecy	256
@Synchro
Synchro / gist:5917252
Last active Mar 18, 2016
Logstash config for parsing drupal watchdog log entries. Greps the syslog_program source first to check it's logged by drupal, then takes apart the watchdog log pattern. See: https://api.drupal.org/api/drupal/modules!syslog!syslog.module/function/syslog_watchdog/7
View gist:5917252
grep {
type => "syslog"
match => [ "syslog_program", "drupal" ]
add_tag => "Drupal"
drop => false
}
grok {
type => "syslog"
tags => [ "Drupal" ]
match => [ "@message", "^https?://%{HOSTNAME:drupal_vhost}\|%{NUMBER:drupal_timestamp}\|(?<drupal_action>[^\|]*)\|%{IP:drupal_ip}\|(?<drupal_request_uri>[^\|]*)\|(?<drupal_referer>[^\|]*)\|(?<drupal_uid>[^\|]*)\|(?<drupal_link>[^\|]*)\|(?<drupal_message>.*)" ]