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 BoundingBox.php
<?php
/**
* Class BoundingBox
*/
class BoundingBox {
/**
* @var float $lat
* @var float $lon
@lloc
lloc / proxy.py
Last active Apr 26, 2019
Configure GitHub for a connection trough a proxy with a pacfile
View proxy.py
#!/usr/bin/env python
"""
The config.ini contains something like:
[Proxy]
proxy = http://YOURPROXY/proxy.pac
user = YOURUSER
pass = YOURPASS
local = proxy.pac
View wordpress-json-server.php
<?php
/*
Plugin Name: WordPress serves JSON
Description: Serve your content as JSON or JSONP in a simple manner (based on an example by Jon Cave - http://make.wordpress.org/plugins/2012/06/07/rewrite-endpoints-api/).
Plugin URI: https://gist.github.com/lloc/8933914
Author: realloc
Author URI: http://lloc.de/
*/
namespace LLOC\realloc;
View abstract-method-overriding.php
<?php
namespace wctrn\realloc;
abstract class Option {
abstract function get( int $id );
}
View interface-widening.php
<?php
namespace wctrn\realloc;
interface Thing {
public function the_content( string $content ) : void;
}
class Tag implements Thing {
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 trait.php
<?php
namespace wctrn\realloc;
trait Logger {
public function log_error( string $msg ) : bool {
return error_log( $msg );
}
}
View exceptions-error-handling.php
<?php
try {
// Something throws an Exception or Error.
} catch ( Throwable $t ) {
// will match only in PHP 7
} catch ( Exception $e ) {
// will be reached in PHP 5
}
You can’t perform that action at this time.