Skip to content

Instantly share code, notes, and snippets.

View evansims's full-sized avatar

Evan Sims evansims

View GitHub Profile
@evansims
evansims / decrypt.php
Last active March 18, 2024 08:39
AES-256-GCM w/ PHP 7.1+ OpenSSL
<?php
public function decrypt($secret, $data)
{
$secret = hex2bin($secret);
$iv = base64_decode(substr($data, 0, 16), true);
$data = base64_decode(substr($data, 16), true);
$tag = substr($data, strlen($data) - 16);
$data = substr($data, 0, strlen($data) - 16);
try {
@evansims
evansims / gender_pronouns.js
Last active March 7, 2024 09:19
English Gender Pronouns JS/JSON
gender: {
nominative: {
neutral: 'they',
masculine: 'he',
feminine: 'she',
elverson: 'ey',
spivak: 'E',
humanist: 'hu',
peh: 'peh',
per: 'per',
@evansims
evansims / Dockerfile
Last active February 14, 2024 10:09
Dockerfile: php-fpm 7.4-fpm alpine w/ gd bz2 intl mbstring redis mongodb xdebug opcache
FROM php:7.4-fpm-alpine
WORKDIR "/application"
# Install essential build tools
RUN apk add --no-cache \
git \
yarn \
autoconf \
g++ \
make \
@evansims
evansims / example.html
Last active February 5, 2024 16:52
Embedding or sharing a image or photo uploaded to Google Drive.
<a href="https://drive.google.com/uc?export=view&id=XXX"><img src="https://drive.google.com/uc?export=view&id=XXX" style="width: 500px; max-width: 100%; height: auto" title="Click for the larger version." /></a>
@evansims
evansims / script.js
Last active February 16, 2023 00:43
Google Apps Script: Sync Google Group members Out of Office events to a shared calendar, including recurring OOF events, using the outOfOffice eventType.
/**
This is based on the example provided at:
https://developers.google.com/apps-script/samples/automations/vacation-calendar
The following changes were made:
- Uses the outOfOffice eventType to identify events to sync. It does not use a keyword search.
- Events use the full names of members, pulled from the Google Workspace API (AdminDirectory.)
- Recurring OOF events are supported.
- Creates "shadow events" instead of importing the actual events, to circumvent "forbidden" errors in some cases, and issues with recurring events.
@evansims
evansims / Octagon
Created April 21, 2019 21:33
Monokai Pro Slack Theme
#1E1F2B,#1E1F2B,#282A3A,#FFD76D,#1E1F2B,#9A9DA7,#95E18A,#F47777
@evansims
evansims / hooks.php
Last active May 20, 2020 19:27
An example of automatically including header and footer templates using Slim hooks.
$app->hook('slim.before.dispatch', function () use ($app) {
$app->render('/views/header.php');
});
$app->hook('slim.after.dispatch', function () use ($app) {
$app->render('/views/footer.php');
});
@evansims
evansims / WilsonConfidenceIntervalCalculator.php
Created April 10, 2017 23:03 — forked from mbadolato/WilsonConfidenceIntervalCalculator.php
PHP translation of the Wilson ConfidenceInterval Calculator. Ported from Ruby and uses a hardcoded (pre-calculated) confidence (z value) instead of a dynamic calculation with a translation of Ruby's Statistics2.pnormaldist method. Since z doesn't change once it's computed, nor is the computation dependant on the passed-in values, calculating it …
<?php
/*
* (c) Mark Badolato <mbadolato@gmail.com>
*
* This content is released under the {@link http://www.opensource.org/licenses/MIT MIT License.}
*/
namespace Bado\ScoreCalculator;
@evansims
evansims / Prerequisites
Created November 13, 2012 01:26
SQL Backups0rz
apt-get install pigz
@evansims
evansims / backup_mysqld.sh
Created March 5, 2012 15:17
Backup Databases to Individual ZIPs
#!/bin/bash
mysqlUser=""
mysqlPass=""
backup="/home/username/mysqldump"
databases=( $(mysql -u"$mysqlUser" -p"$mysqlPass" --skip-column-names --batch -e "show databases;" 2>"$temp") );
echo "found ${#databases[@]} databases.";
for i in ${databases[@]}; do