Skip to content

Instantly share code, notes, and snippets.

Bubba bubba-h57

Block or report user

Report or block bubba-h57

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bubba-h57
bubba-h57 / parallel_stub.php
Created Sep 10, 2019
Stub File for PHP extension parallel
View parallel_stub.php
<?php declare(strict_types=1);
/**
* A helper file for providing autocomplete information for your IDE.
*
* This file should not be included in your code, only analyzed by your IDE!
*
* @author Bubba Hines <bubba@stechstudio.com>
*/
@bubba-h57
bubba-h57 / phpbuild.sh
Created Feb 7, 2019
Build Similar PHP 7.2 & 7.3 Debug/Pthreaded Builds on the same system using phpbrew
View phpbuild.sh
#!/usr/bin/env bash
brew install openssl
brew install gd
brew install imagemagick
brew install libmemcached
brew services start memcached
phpbrew install --name 7.3-debug php-7.3 \
+zts \
+debug \
@bubba-h57
bubba-h57 / LockerRoom.py
Created May 1, 2018
Simple Distributed Advisory Locking Class for AWS Lambda
View LockerRoom.py
import os
import redis
import logging
import string
import random
from collections import namedtuple
from redis.exceptions import RedisError
Lock = namedtuple("Lock", ("valid", "resource", "key", "ttl"))
@bubba-h57
bubba-h57 / test.php
Created Sep 26, 2017
Have a function timeout on itself
View test.php
<?php
try {
test();
} catch (TimeoutException $e) {
$e->handle();
} catch (Throwable $t) {
printf('Some other error occured. %s', $t->getMessage());
}
@bubba-h57
bubba-h57 / luthers_insults.js
Created Aug 25, 2017
Generate Random Citations of Martin Luther Insults
View luthers_insults.js
var insults = [
{
"work": "Heidelberg Disputation from Vol. 31 of Luther's Works.",
"quotes": [
{
"page": "51",
"quote": "Your sin smells to high heaven."
}
]
},
@bubba-h57
bubba-h57 / NonBreakableSnakeCase.php
Last active Jul 5, 2017
Convert studly, traditional snake, and kebob case strings into a non-breakable snake case string.
View NonBreakableSnakeCase.php
<?php
function non breakable snake case($value, $delimiter = ' ')
{
$value = ucwords(str_replace(['-', '_'], ' ', $value));
if (! ctype_lower($value)) {
$value = preg_replace('/\s+/u', '', $value);
$value = mb_strtolower(preg_replace('/(.)(?=[A-Z])/u', '$1'.$delimiter, $value), 'UTF-8');
}
@bubba-h57
bubba-h57 / .php_cs
Created Jun 21, 2017
My favorite Code Style Rules for php-cs-fixer
View .php_cs
<?php
$rules = [
'@PSR2' => true,
// Additional Non-PSR2 rules
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => ['align_double_arrow' => true],
'blank_line_after_opening_tag' => true,
'blank_line_before_return' => true,
@bubba-h57
bubba-h57 / helpers.php
Created Jun 19, 2017
Various PHP Helper Functions I Regularly Use
View helpers.php
<?php
if (!function_exists('human_filesize')) {
/**
* From http://jeffreysambells.com/2012/10/25/human-readable-filesize-php
*
* @param int $bytes
* @param int $decimals
* @param string $separator
*
* @return string
@bubba-h57
bubba-h57 / times.sh
Created Apr 25, 2017
Run a command 100 times and get the average.
View times.sh
#!/bin/bash
rm -f /tmp/mtime.$$
for x in {1..100}
do
/usr/bin/time -f "real %e user %U sys %S" -a -o /tmp/mtime.$$ $@
tail -1 /tmp/mtime.$$
done
@bubba-h57
bubba-h57 / Homestead.yaml
Last active Oct 11, 2017
after.sh for Homestead
View Homestead.yaml
variables:
- key: STS_USER
value: "<your name>"
- key: STS_HOME
value: "<your customized home dir>"
- key: AWS_ACCESS_KEY_ID
value: "<your key>"
- key: AWS_SECRET_ACCESS_KEY
value: "<your secret>"
- key: AWS_DEFAULT_REGION
You can’t perform that action at this time.