Skip to content

Instantly share code, notes, and snippets.

Anthony Ferrara ircmaxell

Block or report user

Report or block ircmaxell

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 index.php
<?php
declare(ticks=1);
$__stack = [];
function getArrayKey(array $haystack, $needle) {
return isset($haystack[$needle]) ? $haystack[$needle] : '';
}
@ircmaxell
ircmaxell / HashCipher.php
Created Mar 24, 2014
A hash based cipher built using a Feistel Network
View HashCipher.php
<?php
class HashCipher {
protected $hash = 'sha512';
protected $hashLen = 64;
protected $rounds = 16;
public function __construct($hash, $rounds = 16) {
$this->hash = $hash;
// run a test hash, to get the proper hash length
View keybase.md

Keybase proof

I hereby claim:

  • I am ircmaxell on github.
  • I am ircmaxell (https://keybase.io/ircmaxell) on keybase.
  • I have a public key whose fingerprint is D620 2127 D88F 66C2 10A3 BFEB 6A7C A4E4 A190 DC6B

To claim this, I am signing this object:

View gist:bc05919d13781d3c5569
<?hh
class B {
public function doB() : string {
return "b";
}
}
class C extends B {
public function doC() : string {
@ircmaxell
ircmaxell / a.php
Created May 8, 2014
PHP Is Drunk
View a.php
<?php
class a {
const a = b::c;
const b = b::d;
}
@ircmaxell
ircmaxell / template.pseudo
Created Jul 8, 2014
Go return polymorphism pseudo-code
View template.pseudo
interface Foo1 {
public function bar()
}
interface Foo2 {
public function bar()
}
interface Foo3 {
public function bar()
View ackersum.php
<?php
function ackersum($a, $b) {
if ($a == 0) {
return $b;
} elseif ($b == 0) {
return $a;
} elseif ($a == 1) {
return $b + 1;
}
View crypt_sha.php
<?php
define('CRYPT_SALT_LEN_MAX', 16);
define('CRYPT_ROUNDS_DEFAULT', 5000);
/**
* A PHP shim for crypt sha256 and sha512
* to workaround bug 62372
* @see https://bugs.php.net/bug.php?id=62372
*/
View gist:6fa2ea9417056be7aba7
13:11 <ajf> I’m mostly happy with it as-is, but given that I made int/float/numeric/string not accept NULL, I think booleans shouldn’t be accepted for them either.
13:19 → arty joined ⇐ DaveRand quit
13:49 → sonotos and lonnylot joined ⇐ dmitry and RemiFedor quit
14:41 <ircmaxell> ajf: that sounds sane (consistency wise). So it means that `int/float/numeric` only accept int/float/valid-number-string, and string only accepts string/int/float
14:43 <ajf> ircmaxell: Yeah
14:43 <ajf> Also, we don’t accept int/float/string for bool, so we shouldn’t accept bool for int/float/string
14:43 <ircmaxell> yeah, makes perfect sense
14:44 <ajf> Another point someone raised was that FALSE is a common error value alongside NULL.
14:44 <ajf> So, should I go ahead and amend the patch and RFC to do that?
14:44 <ircmaxell> I think that's the direction we're going, so that's valid
View step0.php
<?php
/**
* @param int
* @param int
* @return int
*/
function foo($a, $b) {
$c = 0;
if ($a) {
You can’t perform that action at this time.