Skip to content

Instantly share code, notes, and snippets.

View tuupola's full-sized avatar

Mika Tuupola tuupola

View GitHub Profile
@tuupola
tuupola / MonologSQLLogger.php
Last active June 12, 2017 04:33
Monolog logging with Spot2 and Slim
<?php
/* This is old, use https://github.com/tuupola/dbal-psr3-logger instead. */
namespace Doctrine\DBAL\Logging;
class MonologSQLLogger implements SQLLogger {
public $logger;
public $sql = "";
@tuupola
tuupola / index.php
Created April 18, 2015 14:03
Sample JWT workflow with HTTP Basic Auth
<?php
use \Slim\Middleware\JwtAuthentication;
use \Slim\Middleware\JwtAuthentication\RequestPathRule;
use \Slim\Middleware\HttpBasicAuthentication;
/* Setup Slim */
$app = new \Slim\Slim();
$app->add(new JwtAuthentication([
@tuupola
tuupola / index.php
Last active March 4, 2019 09:47
Use JWT Authentication middleware with ZF Expressive
<?php
use Zend\Expressive\AppFactory;
use Firebase\JWT\JWT;
use Slim\Middleware\JwtAuthentication;
chdir(dirname(__DIR__));
require "vendor/autoload.php";
$app = AppFactory::create();
@tuupola
tuupola / index.php
Created June 10, 2016 08:44
CORS middleware with Zend Expressive
<?php
use Zend\Expressive\AppFactory;
require __DIR__ . "/../vendor/autoload.php;
$app = AppFactory::create();
$app->pipe(new \Tuupola\Middleware\Cors([
"origin" => ["*"],

Keybase proof

I hereby claim:

  • I am tuupola on github.
  • I am tuupola (https://keybase.io/tuupola) on keybase.
  • I have a public key ASDd8KUHc2ysqd2rplSt3onYRIq3UJ8zqnnADb2dg0KWlgo

To claim this, I am signing this object:

<?php
require __DIR__ . "/vendor/autoload.php";
use Http\Client\Curl\Client;
use Http\Message\MessageFactory\DiactorosMessageFactory;
use Http\Message\StreamFactory\DiactorosStreamFactory;
use Http\Discovery\HttpAsyncClientDiscovery;
use Http\Discovery\HttpClientDiscovery;
use Psr\Http\Message\ResponseInterface;
<?php
require __DIR__ . "/vendor/autoload.php";
use Http\Client\Curl\Client as Curl;
use Http\Adapter\React\Client as React;
use Http\Adapter\Guzzle6\Client as Guzzle;
use Http\Client\Socket\Client as Socket;
use GuzzleHttp\Client as GuzzleClient;
use Http\Message\MessageFactory\DiactorosMessageFactory;
@tuupola
tuupola / plugin.php
Last active November 11, 2016 12:10
<?php
require __DIR__ . "/vendor/autoload.php";
use Http\Client\Curl\Client as Curl;
use Http\Adapter\React\Client as React;
use Http\Adapter\Guzzle6\Client as Guzzle;
use GuzzleHttp\Client as GuzzleClient;
use Http\Client\Socket\Client as Socket;
use Http\Client\Common\PluginClient;
$ vendor/bin/phpunit --testsuite=Slim
PHPUnit 5.7.15 by Sebastian Bergmann and contributors.
.F.F.............................F...................F.... 58 / 58 (100%)
Time: 1.65 seconds, Memory: 6.00MB
There were 4 failures:
1) Http\Psr7Test\Tests\Slim\RequestTest::testMethod
@tuupola
tuupola / protomower.sh
Last active June 29, 2021 21:52
Extract protocol buffer messages from binary data
#!/bin/bash
#
# Try to decode hidden protocol buffers message from binary
size=$(wc -c < $1)
for ((i=1; i<=$size; i++))
do
# Skip $i bytes and decode
dd if=$1 bs=1 skip=$i | protoc --decode_raw