Skip to content

Instantly share code, notes, and snippets.

View AndrewCarterUK's full-sized avatar

Andrew Carter AndrewCarterUK

View GitHub Profile
@AndrewCarterUK
AndrewCarterUK / breaking-boundaries-with-fastcgi.md
Last active September 4, 2015 10:51
Talk Proposal: Breaking Boundaries with FastCGI

Breaking Boundaries with FastCGI

Efficient and performant applications are fantastic; they keep server load, costs and response times low. We can make our web applications more efficient by removing the repetitive bootstrapping process from the request-response cycle.

"How?" I hear you ask!

By using FastCGI we can keep our application alive between requests and vastly improve their performance. The best news is that if you're using a Request-Response framework (such as Symfony) you can probably do this to your application by adding one line to your composer dependencies file.

Let us not get too excited, however! When using PHP in this way we have to be very careful about the design and configuration of our application! This talk will explain how to use FastCGI with our applications safely, providing an overview of the process and highlighting the danger areas that we must be cautious of.

@AndrewCarterUK
AndrewCarterUK / psr-6-testing-example.php
Created September 30, 2015 13:12
PSR-6 Pool::resolveItem() Testing Example
<?php
class MyClass
{
private $pool;
public function __construct(CacheItemPoolInterface $pool) { $this->pool = $pool; }
public function getDataA($param)
{
return $this->pool->resolveItem(
<?php
/**
* What an async proxy server might look like in PHP with a PSR for event loops
*/
use EventLoopImplementation\EventLoop;
use HttpClientImplementation\HttpClient;
use HttpServerImplementation\HttpServer;
use PromiseImplementation\Promise;
@AndrewCarterUK
AndrewCarterUK / class-preloading.php
Last active February 12, 2016 16:01
Class "preloading" with Composer
<?php
/*
This should work because composer registers a callback using
'spl_autoload_register' for when a class is used that has not
already been loaded. Loading the class before hand will
prevent that callback being triggered by PHP.
*/
@AndrewCarterUK
AndrewCarterUK / sitepoint-survey-parser.php
Last active May 12, 2016 10:53
Verifying PHPixie fraud on SitePoint survey
<?php
// https://raw.githubusercontent.com/sitepoint-editors/php-fw-survey-2015/master/dump/survey.csv
$stream = fopen('survey.csv', 'r');
$headers = fgetcsv($stream);
$count = 0;
$phpixieCount = 0;
$nonPhpixieErrorCount = 0;

Keybase proof

I hereby claim:

  • I am AndrewCarterUK on github.
  • I am andrewcarteruk (https://keybase.io/andrewcarteruk) on keybase.
  • I have a public key whose fingerprint is 816F E758 8C26 645F DEC6 AEC3 7A29 1B28 6F00 60B0

To claim this, I am signing this object:

@AndrewCarterUK
AndrewCarterUK / GPS.php
Last active August 10, 2016 11:00
GPS NMEA Parser in PHP. Tested on a Raspberry Pi with a GY-GPS6MU2.
<?php
class GPS
{
private $serialFile;
public function __construct($serialFile)
{
$this->serialFile = $serialFile;
}
@AndrewCarterUK
AndrewCarterUK / phpixie-stats.php
Created May 9, 2016 14:07
Script used to verify fraudulent installs on PHPixie.
<?php
function getJsonPage($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
@AndrewCarterUK
AndrewCarterUK / gchq-puzzle.c
Last active July 3, 2017 22:21
Programming solution to the GCHQ puzzle on BBC Radio 4, Mon 3rd July 2017
/**
* Programming solution to the GCHQ puzzle on BBC Radio 4, Mon 3rd July 2017
* http://www.bbc.co.uk/programmes/articles/5wkxjTtqRvq8Cyrrjxtk7tc/puzzle-for-today
*
* Output:
* 4 -> 123+45-67+8-9
* 4 -> 123+4-5+67-89
* 3 -> 123-45-67+89
* 6 -> 123-4-5-6-7+8-9
* 6 -> 12+3+4+5-6-7+89
@AndrewCarterUK
AndrewCarterUK / test.c
Created July 19, 2017 13:21
LoRa Confusion
/*
This program attempts to change the operation mode of a SX1276.
SPI communication is verified as working, as the program is able to select and verify sleep mode.
The SX1276 refuses to enter RXCONTINUOS mode and instead reverts back to STDBY·
Compile:
gcc test.c -lwiringPi -o test