Skip to content

Instantly share code, notes, and snippets.

View PurpleBooth's full-sized avatar

Billie Thompson PurpleBooth

View GitHub Profile
$total = ($origCount * $origRating) + $rating;
$number = $origCount + $count;
if ($number > 0) {
$origRating = $total / $number;
$origCount = $number;
return [$origRating, $origCount];
} else {
$origRating = 0;
$origCount = 0;
return [$origRating, $origCount];
[PHP]
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.
; PHP attempts to find and load this configuration from a number of locations.
; The following is a summary of its search order:
@PurpleBooth
PurpleBooth / gist:2a03e16da68df7877c24
Created February 23, 2015 07:08
Composer Require
$ php composer.phar require vendor/package1:dev-master
$ php composer.phar require --dev vendor/package2:~1.1.0
### Keybase proof
I hereby claim:
* I am purplebooth on github.
* I am billie (https://keybase.io/billie) on keybase.
* I have a public key whose fingerprint is 5B35 0719 EC0D AE98 C93D 57FA D5D5 0C93 78BF CAB0
To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am purplebooth on github.
  • I am billie (https://keybase.io/billie) on keybase.
  • I have a public key whose fingerprint is 5B35 0719 EC0D AE98 C93D 57FA D5D5 0C93 78BF CAB0

To claim this, I am signing this object:

<?php
if(count($argv) != 2) {
echo "Attempt to recursively convert a directory of XML files to UTF-8 and Fix any unescaped & symbols\n";
echo "Usage {$argv[0]} directory\n";
exit(1);
}
$path = realpath($argv[1]);
@PurpleBooth
PurpleBooth / kubernetes-abstract.md
Last active September 24, 2015 12:38
Kubernetes Talk Abstract

At the Home Office we had a problem. Hundreds of lines of infrastructure, everyone doing their own thing, and reinventing the wheel. During this talk I'll tell you how we are attempting resolve that using Docker, Kubernetes and changing developer culture.

This talk consists of 3 parts. In the first I will introduce you to docker and talk about how to use it to create reusable infrastructure components, then I will talk about how to deploy and manage those components with the open source PaaS Kubernetes, and finally I'll talk about changing our culture using tools and techniques to ensure we keep reusing into the future.

protected static function getFieldFlags($what)
{
// Order of flags taken from http://lxr.php.net/xref/PHP_5_6/ext/mysql/php_mysql.c#2507
$constantFlagMap = [
MYSQLI_NOT_NULL_FLAG => "not_null",
MYSQLI_PRI_KEY_FLAG => "primary_key"
...
];
$flags = [];
<?php
// Currently PHPStorm does this
$that->someFunction($aReallyLongFunctionVariable, $aReallyLongFunctionVariable, $aReallyLongFunctionVariable,
$aReallyLongFunctionVariable);
// I want it to do this
$that->someFunction(
$aReallyLongFunctionVariable,
$aReallyLongFunctionVariable,