Skip to content

Instantly share code, notes, and snippets.

View oxyberg's full-sized avatar

Matvey Pravosudov oxyberg

View GitHub Profile
@oxyberg
oxyberg / hook.php
Last active April 17, 2019 22:28
The smallest PHP Hook class (Observer pattern). https://twitter.com/mvoult/status/340782689286250496
class h{private$e;function b($n,$c){$this->e[$n][]=$c;}function c($n){foreach($this->e[$n] as$c)call_user_func($c);}}
@oxyberg
oxyberg / menu.php
Last active July 5, 2016 09:30
Laravel 4 hack for detecting current menu item.
<?php
function menu($url) {
if (preg_match('#' . URL::to($url) . '#', URL::current())) return 'class="active"';
}
<?php
function relative($time) {
$time = [
'year' => 2015,
'month' => 06,
'day' => 07,
'hours' => 10,
'minutes' => 12,
outlet
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4SFyRXhpZgAATU0AKgAAAAgABwEPAAIAAAAGAAAIbgEQAAIAAAANAAAIdAESAAMAAAABAAEAAAEyAAIAAAAUAAAIggITAAMAAAABAAJpPIdpAAQAAAABAAAIluocAAcAAAgMAAAAYgAAAAAc6gAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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