Skip to content

Instantly share code, notes, and snippets.


Chun-Sheng, Li peter279k

Block or report user

Report or block peter279k

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
odan / SameSiteCookieMiddleware.php
Last active Sep 7, 2019
SameSite Cookie Middleware (PSR-15)
View SameSiteCookieMiddleware.php
namespace App\Middleware;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
Seldaek / ext-requires.txt
Last active Sep 23, 2019
PHP Extension Requirements on
View ext-requires.txt
Taken from
Packages with a master branch update since June 1st 2018: 98977
Of those, package having requires on PHP extensions: 11676 (11.79%)
As only ~12% of packages declare their extension requirements,
and even then it might not be a complete list, take all this with
a big grain of salt, it is informative but definitely not a
complete picture of the most used extensions.
odan /
Created Aug 31, 2019
Slim 4 - getBaseUrl middleware

Slim 4 - getBaseUrl middleware

It looks like the App::getBaseUrl method has been removed in Slim 4 (because it's not part of PSR-7).

As replacement you could use this Middleware to detect the baseUrl:


namespace App\Middleware;
bessarabov / gist:674ea13c77fc8128f24b5e3f53b7f094
Last active Oct 21, 2019
One-liner to generate data shown in post 'At what time of day does famous programmers work?' —
View gist:674ea13c77fc8128f24b5e3f53b7f094
git log --author="Linus Torvalds" --date=iso | perl -nalE 'if (/^Date:\s+[\d-]{10}\s(\d{2})/) { say $1+0 }' | sort | uniq -c|perl -MList::Util=max -nalE '$h{$F[1]} = $F[0]; }{ $m = max values %h; foreach (0..23) { $h{$_} = 0 if not exists $h{$_} } foreach (sort {$a <=> $b } keys %h) { say sprintf "%02d - %4d %s", $_, $h{$_}, "*"x ($h{$_} / $m * 50); }'
View zipbomp-detector.php
$filename = '';
echo 'Filename: ' . $filename . "\n";
$zip = new ZipArchive();
$zip->open($filename, ZIPARCHIVE::CHECKCONS);
$size = 0;
View gist:c48704ebe850b0f7f34c7bac2b5d6ee6
public function byId(string $id)
$query = [
'source' => [
'query' => [
'query_string' => [
'fields' => ['id'],
'query' => $id,
peter279k / Dockerfile
Last active Apr 30, 2019
This is Docker image about the PHP+MSSQL enviroment
View Dockerfile
# Install required packages
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get install -y software-properties-common
RUN apt-get install -y python-software-properties
RUN LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
RUN apt-get update
RUN apt-get install -y apt-transport-https apt-utils curl php7.1-cli php7.1-mysql php7.1-curl
RUN apt-get install -y php7.1-xml php7.1-dom php7.1-xsl php7.1-json php7.1-odbc php7.1-dev
RUN apt-get install -y libcurl3-openssl-dev
heineiuo / lint.js
Created Aug 29, 2018
use standardjs with pre-commit hook
View lint.js
const { exec } = require('shelljs')
const path = require('path')
const exit = () => {
console.log('JavaScript Standard Style errors were detected. Aborting commit.')
const gitdiff = exec(`git diff --name-only --cached --relative`)
if (gitdiff.stderr) {
nicolas-grekas /
Last active Jul 18, 2019
RFC for a Secure Unserialization Mechanism in PHP

RFC for a Secure Unserialization Mechanism in PHP


PHP serialization/unserialization has several drawbacks [^1].

On the serialization side, the Serializable interface:

  • breaks hard and soft references inside serialized data structures;
You can’t perform that action at this time.