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
@ircmaxell
ircmaxell / gist:1966809
Created Mar 3, 2012
Scalar Casting Patch, Version 3
View gist:1966809
Index: Zend/zend.h
===================================================================
--- Zend/zend.h (revision 323850)
+++ Zend/zend.h (working copy)
@@ -486,6 +486,10 @@
union _zend_function *__call;
union _zend_function *__callstatic;
union _zend_function *__tostring;
+ union _zend_function *__toint;
+ union _zend_function *__tofloat;
@ircmaxell
ircmaxell / Expressions.php
Created Sep 21, 2011
A math parser and evaluator implementation
View Expressions.php
<?php
class Parenthesis extends TerminalExpression {
protected $precidence = 6;
public function operate(Stack $stack) {
}
public function getPrecidence() {
return $this->precidence;
@ircmaxell
ircmaxell / password.php
Created Jun 18, 2012
Password API Example
View password.php
<?php
define('PASSWORD_SHA256', '$5$');
define('PASSWORD_SHA512', '$6$');
define('PASSWORD_BCRYPT', '$2y$');
define('PASSWORD_SCRYPT', '$7$'); // made up here
$password_algos = array();
function password_register_algo($prefix, Callable $create, Callable $validate) {
@ircmaxell
ircmaxell / equality.php
Last active Apr 19, 2019
Unicode Set Functions
View equality.php
<?php
const= true;
const= false;
function ≠($left, $right) {
return $left != $right;
}
function ≅($left, $right) {
View compile.php
<?php
declare(strict_types=1);
require __DIR__ . '/vendor/autoload.php';
$context = new PHPCompiler\Bootstrap\Context;
$parser = new PHPCompiler\Bootstrap\Parser($context);
$parser->parse(file_get_contents(__DIR__ . "/example.php"), __FILE__);
@ircmaxell
ircmaxell / php_zpp.php
Last active Jan 24, 2019
Zend Parse Parameters. In PHP
View php_zpp.php
<?php
namespace ZPP;
const IS_STRING = "string";
const IS_BOOL = "boolean";
const IS_LONG = "integer";
const IS_DOUBLE = "double";
const IS_ARRAY = "array";
const IS_OBJECT = "object";
@ircmaxell
ircmaxell / gist:a9bfb2dd437458b89250d7190d0c2712
Created Jul 28, 2018
0-A-B != REVERSE(0-REVERSE(A)-REVERSE(B))
View gist:a9bfb2dd437458b89250d7190d0c2712
Hex Dec Binary
A = A0 160 10100000
B = 4C 76 01001100
0 - A
FFFFFF60 -160 1111111101100000 (lowest 16 bits)
0 - A - B
FFFFFF20 -236 1111111100010100 (lowest 16 bits)
Lowest 8 bits of 0-A-B: 00010100
@ircmaxell
ircmaxell / Permutations
Last active Jul 27, 2018
Hamming Distance of 1, changed bits
View Permutations
ACTUAL[0000] CASE[10100001 10000010 01001101 11111111 10010001] XOR[0000] ~XOR[1111] SUM[0000] REVSUM[101110] -REVSUM[0010]
ACTUAL[0000] CASE[10100001 10000010 01001101 11111111 10000001] XOR[0000] ~XOR[1111] SUM[0000] REVSUM[101110] -REVSUM[0010]
ACTUAL[0000] CASE[10100001 11000010 01001100 11111111 11111111] XOR[1111] ~XOR[0000] SUM[1101] REVSUM[101101] -REVSUM[0011]
ACTUAL[0000] CASE[10100001 10000010 01001100 11111111 11111111] XOR[1111] ~XOR[0000] SUM[1101] REVSUM[101101] -REVSUM[0011]
ACTUAL[0000] CASE[10100001 10100011 01001101 11111111 11111111] XOR[1111] ~XOR[0000] SUM[1111] REVSUM[111101] -REVSUM[0011]
ACTUAL[0000] CASE[10100001 10010011 01001101 11111111 11111111] XOR[1111] ~XOR[0000] SUM[1111] REVSUM[111101] -REVSUM[0011]
ACTUAL[0001] CASE[10100001 10100011 01001100 11111111 11111111] XOR[1110] ~XOR[0001] SUM[1110] REVSUM[110101] -REVSUM[1011]
ACTUAL[0001] CASE[10100001 11000010 01001101 11111111 11111111] XOR[1110] ~XOR[0001] SUM[1110] REVSUM[110101] -REVSUM[1011]
ACTUAL[0001] CASE[10100001 1000
@ircmaxell
ircmaxell / gist:eef69bbdaaf4dd5e29af139dc15e092b
Last active Jul 27, 2018
Keystone air conditioner IR protocol debugging
View gist:eef69bbdaaf4dd5e29af139dc15e092b
Toggle Swing: 10100010 00000001
Toggle LED: 10100010 00001000
Set Temp + Mode
Byte 1: 10100001
Byte 2:
|--------|--------|--------|--------|--------|--------|--------|--------|
| POWER | SLEEP | Fan 0 | Fan 1 | FAN 2 | MODE 0 | MODE 1 | MODE 2 |
View interfaces.php
<?php
interface Lock {
public function advisory(string $identifier): LockContext;
public function exclusive(string $identifier): LockContext;
public function waitForAdvisory(string $identifier, int $timeout = 0): \Generator;
public function waitForExclusive(string $identifier, int $timeout = 0): \Generator;
}
interface LockContext {
You can’t perform that action at this time.