Skip to content

Instantly share code, notes, and snippets.

Avatar

Billie Thompson PurpleBooth

View GitHub Profile
View gist:496632b8a6acf756033e
$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];
View gist:8230b36fe8424b5a89a3
[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:
View gist:2a03e16da68df7877c24
$ php composer.phar require vendor/package1:dev-master
$ php composer.phar require --dev vendor/package2:~1.1.0
View gist:a9703afce896c63bf527
### 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:
View keybase.md

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:

View gist:f1c33cc83ab0dd4eaacc
<?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 Sep 24, 2015
Kubernetes Talk Abstract
View kubernetes-abstract.md

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.

View example.php
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 = [];
View example.php
<?php
// Currently PHPStorm does this
$that->someFunction($aReallyLongFunctionVariable, $aReallyLongFunctionVariable, $aReallyLongFunctionVariable,
$aReallyLongFunctionVariable);
// I want it to do this
$that->someFunction(
$aReallyLongFunctionVariable,
$aReallyLongFunctionVariable,