Skip to content

Instantly share code, notes, and snippets.

View michaelbutler's full-sized avatar
💥
Reticulating splines...

Michael Butler michaelbutler

💥
Reticulating splines...
View GitHub Profile
@michaelbutler
michaelbutler / decrypt_file.sh
Last active December 15, 2021 22:06
Bash/shell script to Encrypt and Decrypt an arbitrary file using a passphrase
#!/bin/sh
set -e
# Required ENV variable: ENC_PASSPHRASE
# Usage: ENC_PASSPHRASE=my_super_long_ascii_pass_phrase123 ./decrypt_file.sh encrypted.enc secretfile.json
if [ -z "$ENC_PASSPHRASE" ]; then
echo "ERROR: Required ENC_PASSPHRASE environment variable NOT passed in."
exit 1
@michaelbutler
michaelbutler / php_confusables.php
Created December 15, 2021 22:05
Handle confusable strings in PHP
<?php
$confusables = [
'a' => '(@|⍺|a|𝐚|𝑎|𝒂|𝒶|𝓪|𝔞|𝕒|𝖆|𝖺|𝗮|𝘢|𝙖|𝚊|ɑ|α|𝛂|𝛼|𝜶|𝝰|𝞪|а|A|𝐀|𝐴|𝑨|𝒜|𝓐|𝔄|𝔸|𝕬|𝖠|𝗔|𝘈|𝘼|𝙰|Α|𝚨|𝛢|𝜜|𝝖|𝞐|А|Ꭺ|ᗅ|ꓮ|𖽀|𐊠)',
'b' => '(𝐛|𝑏|𝒃|𝒷|𝓫|𝔟|𝕓|𝖇|𝖻|𝗯|𝘣|𝙗|𝚋|Ƅ|Ь|Ꮟ|ᑲ|ᖯ|B|ℬ|𝐁|𝐵|𝑩|𝓑|𝔅|𝔹|𝕭|𝖡|𝗕|𝘉|𝘽|𝙱|Ꞵ|Β|𝚩|𝛣|𝜝|𝝗|𝞑|В|Ᏼ|ᗷ|ꓐ|𐊂|𐊡|𐌁)',
'c' => '(c|ⅽ|𝐜|𝑐|𝒄|𝒸|𝓬|𝔠|𝕔|𝖈|𝖼|𝗰|𝘤|𝙘|𝚌|ᴄ|ϲ|ⲥ|с|ꮯ|𐐽|🝌|𑣲|𑣩|C|Ⅽ|ℂ|ℭ|𝐂|𝐶|𝑪|𝒞|𝓒|𝕮|𝖢|𝗖|𝘊|𝘾|𝙲|Ϲ|Ⲥ|С|Ꮯ|ꓚ|𐊢|𐌂|𐐕|𐔜)',
'd' => '(ⅾ|ⅆ|𝐝|𝑑|𝒅|𝒹|𝓭|𝔡|𝕕|𝖉|𝖽|𝗱|𝘥|𝙙|𝚍|ԁ|Ꮷ|ᑯ|ꓒ|Ⅾ|ⅅ|𝐃|𝐷|𝑫|𝒟|𝓓|𝔇|𝔻|𝕯|𝖣|𝗗|𝘋|𝘿|𝙳|Ꭰ|ᗞ|ᗪ|ꓓ)',
'e' => '(℮|e|ℯ|ⅇ|𝐞|𝑒|𝒆|𝓮|𝔢|𝕖|𝖊|𝖾|𝗲|𝘦|𝙚|𝚎|ꬲ|е|ҽ|⋿|E|ℰ|𝐄|𝐸|𝑬|𝓔|𝔈|𝔼|𝕰|𝖤|𝗘|𝘌|𝙀|𝙴|Ε|𝚬|𝛦|𝜠|𝝚|𝞔|Е|ⴹ|Ꭼ|ꓰ|𑢦|𑢮|𐊆)',
'f' => '(𝐟|𝑓|𝒇|𝒻|𝓯|𝔣|𝕗|𝖋|𝖿|𝗳|𝘧|𝙛|𝚏|ꬵ|ꞙ|ſ|ẝ|ք|𝈓|ℱ|𝐅|𝐹|𝑭|𝓕|𝔉|𝔽|𝕱|𝖥|𝗙|𝘍|𝙁|𝙵|Ꞙ|Ϝ|𝟊|ᖴ|ꓝ|𑣂|𑢢|𐊇|𐊥|𐔥)',
'g' => '(g|ℊ|𝐠|𝑔|𝒈|𝓰|𝔤|𝕘|𝖌|𝗀|𝗴|𝘨|𝙜|𝚐|ɡ|ᶃ|ƍ|ց|𝐆|𝐺|𝑮|𝒢|𝓖|𝔊|𝔾|𝕲|𝖦|𝗚|𝘎|𝙂|𝙶|Ԍ|Ꮐ|Ᏻ|ꓖ)',
<?php
use GuzzleHttp\Handler\EasyHandle;
/**
* Extends Guzzle's CurlFactory package to enable better control of garbage collection after connections
* are no longer needed.
*/
class MyCurlFactory extends \GuzzleHttp\Handler\CurlFactory
{
#!/usr/bin/php
<?php
use GuzzleHttp\Client;
use Psr\Http\Message\ResponseInterface;
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('error_log', null); // error_log to stderr
@michaelbutler
michaelbutler / guzzletest.php
Created March 13, 2019 02:47
This test script causes file descriptors to stay open until the process quits, even though the local variables all should be cleared out.
#!/usr/bin/php
<?php
use GuzzleHttp\Client;
use Psr\Http\Message\ResponseInterface;
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('error_log', null); // error_log to stderr
@michaelbutler
michaelbutler / instructions.md
Created April 3, 2018 02:43
Guide to Intercept & Inspect SSL or HTTPS requests from an Android App Using a Free Emulator

This guide will take you from start to finish: how to inspect (intercept) SSL (or normal) web requests using Ubuntu 16.04 LTS (Linux). Everything in this guide is free and can be legally obtained.

Components:

  • Android Studio (comes with built in Emulator)
  • Burp Suite Community Edition
  • Terminal

Step 1: Install Android Studio

<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1519158109">
<project timestamp="1519158109">
<package name="MyProj\One">
<file name="/Users/testuser/tmp/phpunit-issue-testing/src/One/One.php">
<class name="MyProj\One\One" namespace="MyProj\One">
<metrics complexity="5" methods="3" coveredmethods="1" conditionals="0" coveredconditionals="0" statements="8" coveredstatements="4" elements="11" coveredelements="5"/>
</class>
<line num="34" type="method" name="__construct" visibility="public" complexity="2" crap="2.06" count="1"/>
<line num="36" type="stmt" count="1"/>
@michaelbutler
michaelbutler / balance.scala
Last active July 21, 2017 22:01
solution for "count change" problem
def balance(chars: List[Char]): Boolean = {
def inner(chars: List[Char], sum: Int): Boolean = {
if (chars.isEmpty)
sum == 0
else {
val c = chars.head.toString()
var newSum = sum
if (c.equals("("))
newSum += 1
else if (c.equals(")"))