Instantly share code, notes, and snippets.

View test.c
/*
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
View gchq-puzzle.c
/**
* 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
View GPS.php
<?php
class GPS
{
private $serialFile;
public function __construct($serialFile)
{
$this->serialFile = $serialFile;
}
View sitepoint-survey-parser.php
<?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;
View phpixie-stats.php
<?php
function getJsonPage($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
View phpixie-sockpuppets.md

See this thread here

/u/dracony Based on the previous comments I updated the base auth project to include separate user and admin logins (totaly separate auth domains), added a .gif demo for the lazy ( http://i.imgur.com/WznceCf.gif ) and the ability to impersonate users.

/u/phpgeek Wow, that's actually something I could use.

/u/underdogging10 Just gonna throw this out there... but you seem to always post positively on any PHPixie post shortly after it is posted. Pretty sure this is just /u/dracony. In fact, basically everything you have posted over the last 3 months is just praise of PHPixie.

View class-preloading.php
<?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.
*/
View Event Loop Dreaming.php
<?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;
View psr-6-testing-example.php
<?php
class MyClass
{
private $pool;
public function __construct(CacheItemPoolInterface $pool) { $this->pool = $pool; }
public function getDataA($param)
{
return $this->pool->resolveItem(
View breaking-boundaries-with-fastcgi.md

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.