Skip to content

Instantly share code, notes, and snippets.

View juban's full-sized avatar

Alban Jubert juban

  • Grenoble, France
View GitHub Profile
@juban
juban / GTT_XML_file_fixer.php
Created January 5, 2016 14:39
Google Translator Toolkit XML file fixer
#!/usr/bin/env php
<?php
if(!isset($argv[1]))
die("Please, specify a file to process as argument\n");
$file = $argv[1];
if(!file_exists($file)) {
die("File $file does not exist\n");
}
$pathinfo = pathinfo(realpath($file));
$data = file_get_contents($file);
@juban
juban / yii2-quick-array-add-property.php
Created December 12, 2015 14:38
Yii2 - Quickly add a property to an array using ArrayHelper::getColumn
<?php
require(__DIR__ . '/vendor/autoload.php');
use yii\helpers\ArrayHelper;
use yii\helpers\VarDumper;
$fooArray = [
['name' => 'Han Solo', 'email' => 'han.solo@starwars.com'],
['name' => '', 'email' => 'luc.skywalker@starwars.com'],
@juban
juban / EFastDbAuthManager.php
Last active January 4, 2016 11:59
This class inherit from and is an enhancement for CDbAuthManager class from Yii Framework 1.1 which lower the number of database queries.
<?php
/**
* EFastDbAuthManager class file
*
* This class inherit from and is an enhancement for CDbAuthManager class which lower the number of database queries.
* The main difference with the original class is that the authorization data are loaded once for all in a very a similar way to CPhpAuthManager.
* In short terms, this is a kind of mix between CDbAuthManager and CPhpAuthManager classes to get the best of both worlds.
* The class can also be used to cache the authorization data to achieve an even faster loading.
*
@juban
juban / iOSPNGNormalizer.php
Last active February 15, 2021 07:20
PHP iOS PNG normalizer. This PHP class can be used to convert an iOS compressed PNG (CgBI format files) back to the standard format. Requires PHP 5.4 or greater. Credit goes to Axel E. Brzostowski for the original Python version of this script: http://www.axelbrz.com.ar/?mod=iphone-png-images-normalizer
<?php
class iOSPNGNormalizer
{
public static function fix($filename, $destfilename = null)
{
try {
$handle = fopen($filename, "rb");
$oldPNG = fread($handle, filesize($filename));
fclose($handle);