Skip to content

Instantly share code, notes, and snippets.

Dennis Ploetner lloc

Block or report user

Report or block lloc

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
View trait.php
<?php
namespace wctrn\realloc;
trait Logger {
public function log_error( string $msg ) : bool {
return error_log( $msg );
}
}
View abstract-interface-method-widening.php
<?php
abstract class aFoo {
abstract function baz( int $foobar );
}
abstract class aBar extends aFoo {
// expected type of foobar is still int
abstract function baz( $foobar ) : int;
}
View splat-operator.php
<?php
function variadic_sum( int ... $args ) {
return array_sum( $args );
}
// echoes 6
echo variadic_sum( 1, 2, 3 ), PHP_EOL;
$a = [ 1, 2, 3 ];
View generators.php
<?php
function xrange( $start, $limit, $step = 1 ) {
for ( $i = $start; $i <= $limit; $i += $step ) {
yield $i;
}
}
/*
* An array is never created or returned
View closures-in-wp.php
<?php
// Sort an array of objects by name
usort( $arr, function ( $a, $b ) {
return strcmp( $a->name, $b->name );
} );
function callback_function_name() {
// do something
}
@lloc
lloc / nvm-update.sh
Created Feb 16, 2018
Use nvm for node-update
View nvm-update.sh
nvm ls-remote
nvm install --lts
@lloc
lloc / nvm-install.sh
Last active Feb 16, 2018
Ubuntu 16.04: install nvm
View nvm-install.sh
sudo apt update
sudo apt install build-essential libssl-dev
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
@lloc
lloc / node-npm-install.sh
Last active Feb 16, 2018
Ubuntu 16.04: install node and npm
View node-npm-install.sh
sudo apt update
sudo apt install nodejs nodejs-legacy npm
@lloc
lloc / changelog.php
Created Jan 2, 2018
Script for the changelog.php post
View changelog.php
<?php
namespace lloc\changelog;
exec( 'git fetch --tags' );
$cmd = 'git tag -l --format="%(creatordate:iso8601)|%(refname:short)" | sort -r';
$arr = ( new ArrayOutput( $cmd ) )->get();
$tags = new Tags( $arr );
@lloc
lloc / Logs.php
Created Jan 2, 2018
Class of the changelog.php post
View Logs.php
<?php
namespace lloc\changelog;
class Logs {
/**
* @var array
*/
protected $logs = [];
You can’t perform that action at this time.