Skip to content

Instantly share code, notes, and snippets.

Benjamin Zaslavsky Tiriel

  • Paris
Block or report user

Report or block Tiriel

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 onename.txt
Verifying that "bzaslavskytiriel.id" is my Blockstack ID. https://onename.com/bzaslavskytiriel
@Tiriel
Tiriel / deepcompare.php
Created Aug 26, 2017
Deep recursive comparing tool
View deepcompare.php
<?php
class DeepCompare
{
/**
* Deep recursive comparison tool.
* Function ca be used as basis for comparison and update tool. Un-static function and add updating tools (setters)
*
* @param $var1
* @param $var2
@Tiriel
Tiriel / encryption.js
Created Aug 26, 2017
Symetric encryption/decryption for PHP and NodeJS communication
View encryption.js
'use strict';
const crypto = require('crypto');
const AES_METHOD = 'aes-256-cbc';
const IV_LENGTH = 16; // For AES, this is always 16, checked with php
const password = 'lbwyBzfgzUIvXZFShJuikaWvLJhIVq36'; // Must be 256 bytes (32 characters)
function encrypt(text, password) {
@Tiriel
Tiriel / utilities.js
Last active Aug 28, 2017
NodeJS utilities (outgoing requests interceptor, unhandledRejection monitor)
View utilities.js
'use-strict';
/**
* Debug toolbox startng point
* Usage :
* const utilities = require('path-to-utilities.js');
* utilities.requestLogger(require('http'));
* utilities.unhandledRejectionMonitor();
*/
module.exports.requestLogger = function(httpModule){
let original = httpModule.request;
@Tiriel
Tiriel / set-and-get.php
Last active Sep 15, 2017
Universal __set and __get methods
View set-and-get.php
<?php
/**
* @param $name
* @param $value
* @return $this
*/
function __set($name, $value)
{
$reflected = new \ReflectionClass($this);
$property = $reflected->getProperty($name);
@Tiriel
Tiriel / request_dump.sh
Last active Jan 6, 2017
Symfony Request dump
View request_dump.sh
object(Symfony\Component\HttpFoundation\Request)#4 (21) {
["attributes"]=>
object(Symfony\Component\HttpFoundation\ParameterBag)#7 (1) {
["parameters":protected]=>
array(6) {
["id"]=>
string(5) "11832"
["provider"]=>
NULL
@Tiriel
Tiriel / Slugifier.php
Created Nov 9, 2016
Small sluggifier static function. Simply call Slugifier::slugify($string)
View Slugifier.php
<?php
class Slugifier
{
public static function slugify($string)
{
$aArray = array('à', 'â', 'ä');
$eArray = array('é', 'è', 'ê', 'ë');
$iArray = array('î', 'ï');
$oArray = array('ô', 'ö');
$uArray = array('ù');
@Tiriel
Tiriel / array_to_xml.php
Created Oct 19, 2016
Function found on StackOverflow
View array_to_xml.php
<?php
// function defination to convert array to xml
function array_to_xml( $data, &$xml_data ) {
foreach( $data as $key => $value ) {
if( is_numeric($key) ){
$key = 'item'.$key; //dealing with <0/>..<n/> issues
}
if( is_array($value) ) {
$subnode = $xml_data->addChild($key);
array_to_xml($value, $subnode);
@Tiriel
Tiriel / class_casting.php
Last active Sep 7, 2016
Class casting function from StackOverflow
View class_casting.php
<?php
/**
* Class casting
*
* @param string|object $destination
* @param object $sourceObject
* @return object
*/
function cast($destination, $sourceObject)
{
@Tiriel
Tiriel / proper_parse_str.php
Last active Aug 2, 2016
Custom function for URL parsing
View proper_parse_str.php
<?php
/**
* Custom version of parse_str function to avoid overriding of multiple definitions in query string
*
* @param $string
* @return array
*/
function proper_parse_str($string)
{
$array = array();
You can’t perform that action at this time.