Skip to content

Instantly share code, notes, and snippets.

Arnold Daniels jasny

Block or report user

Report or block jasny

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
@jasny
jasny / PasswordResetController.php
Last active Nov 29, 2019
Example controllers for Jasny PHP framework
View PasswordResetController.php
<?php
declare(strict_types=1);
use Jasny\Auth;
use Jasny\Auth\Confirmation\InvalidTokenException;
use Jasny\Persist\Gateway;
use Jasny\Session;
use Psr\Http\Message\ResponseInterface as Response;
@jasny
jasny / CMakeList.txt
Created Oct 7, 2019
CMake configuration for php-src
View CMakeList.txt
cmake_minimum_required(VERSION 3.8)
project(php C)
# 32bit or 64bit
set(BITNESS 32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(BITNESS 64)
endif()
# Global definitions
@jasny
jasny / object_init.php
Last active Oct 2, 2019
Set the properties (including protected and private) of an object
View object_init.php
<?php
/**
* Set the properties (including protected and private) of an object.
* This should only be called by the object itself.
*/
function object_init(object $object, array $values): void
{
$init = function ($values) {
foreach ($values as $prop => $value) {
@jasny
jasny / build-packagexml.php
Last active Sep 11, 2019
Build package.xml for PECL extensions
View build-packagexml.php
<?php
/**
* Generate package.xml for pecl extensions.
* Works for new and existing extensions.
*
* Add it to `Makefile.frag`
* package.xml: php_$(PHP_PECL_EXTENSION).h
* $(PHP_EXECUTABLE) build-packagexml.php
*
@jasny
jasny / Email.php
Created Sep 4, 2019
Use Twig with PHPMailer
View Email.php
<?php
/**
* Render and send e-mail
*/
class Email extends PHPMailer
{
/**
* @var Twig_Environment
*/
@jasny
jasny / poc-standard.php
Created Jun 26, 2019
Proof of concept where `strict_types` affects `==` and `!=` operators
View poc-standard.php
<?php
var_dump("1" == 1);
var_dump("1" != 1);
@jasny
jasny / gen.php
Last active Jun 25, 2019
rfc:strict_operators - Generate every combination of operands and operators
View gen.php
<?php
$one = [
'arithmetic' => ['+$a', '-$a'],
'bitwise' => ['~$a'],
'incdec' => ['++$a', '--$a'],
'logical' => ['!$a'],
];
$two = [
@jasny
jasny / livecontract-yaml-to-json.php
Created Jun 13, 2019
Script to convert Live Contract scenario Yaml to JSON
View livecontract-yaml-to-json.php
<?php
$file = $argv[1];
$tagToStruct = function($value, $tag) {
$key = substr($tag, 1);
return ["<$key>" => $value];
};
$callbacks = [
@jasny
jasny / magic_8_ball.php
Last active May 27, 2019 — forked from happy-box/magic_8_ball.py
Simple magic 8-ball game written in PHP
View magic_8_ball.php
#!/usr/bin/env php
<?php
/**
* Magic 8 Ball IRC bot
* Created by Lance Brignoni
* Converted to PHP by Arnold Daniels
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
@jasny
jasny / sha256-hmac.md
Last active Nov 23, 2019
Hashing examples in different languages
View sha256-hmac.md

Example inputs:

Variable Value
key the shared secret key here
message the message to hash here

Reference outputs for example inputs above:

| Type | Hash |

You can’t perform that action at this time.