Skip to content

Instantly share code, notes, and snippets.

View lechimp-p's full-sized avatar

Richard Klees lechimp-p

View GitHub Profile
@lechimp-p
lechimp-p / reversing_the_technical_interview.php
Created October 10, 2020 13:56
This is Aphyrs "Reversing the technical interview" in PHP.
<?php
// This is Aphyrs "Reversing the technical interview" in PHP.
// https://aphyr.com/posts/340-reversing-the-technical-interview
function cons($a, $b) {
return function ($x) use ($a, $b) {
return $x ? $a : $b;
};
}
@lechimp-p
lechimp-p / foreach_type_hinted.php
Last active April 22, 2017 22:20
A type-hinted foreach in PHP.
<?php
// This seems to be incredibly usefull when arrays are passed that should
// have elements with the same type.
foreach ($array as $key => $value) (function ($key, SomeClass $value) {
// We know the $value has SomeClass now and this still looks like an
// ordinary recursion.
})($key, $value);
Result of analysis:
################################################################################
WholeIliasCodebase cannot invoke triggerError
-> 5 Violations
################################################################################
Services/Component/classes/class.ilClaimingPermissionHelper.php (180):
@lechimp-p
lechimp-p / 0-ilias-dicto-rules.php
Last active May 22, 2016 12:29
Analysis of ILIAS with php-dicto (proof of concept)
<?php
/**
* Straight forward translation of the dicto rules for ILIAS to php-dicto. The
* results look different than the original analysis, so this is not to be trusted.
* This rather is a proof of concept that php-dicto can process the ILIAS codebase.
*/
use Lechimp\Dicto\Dicto as D;