Skip to content

Instantly share code, notes, and snippets.

View bizley's full-sized avatar
🖤
Kurald Galain user

Bizley bizley

🖤
Kurald Galain user
View GitHub Profile
<?php
namespace app\models;
use yii\base\Model;
use Yii;
/**
* Simplified model with validation rules.
* All characters are allowed (you want emojis in the password? Go ahead).
@bizley
bizley / countries-iso.php
Created May 27, 2016 17:57
Contries ISO codes
<?php
$countries = [
'AF' => Yii::t('app/countries', 'Afghanistan'),
'AL' => Yii::t('app/countries', 'Albania'),
'DZ' => Yii::t('app/countries', 'Algeria'),
'AS' => Yii::t('app/countries', 'American Samoa'),
'AD' => Yii::t('app/countries', 'Andorra'),
'AO' => Yii::t('app/countries', 'Angola'),
'AI' => Yii::t('app/countries', 'Anguilla'),
@bizley
bizley / multiimplode.php
Last active March 22, 2016 19:19
Multidimensional array implode (PHP >= 5.4)
/**
* Join array elements with a string.
* This method works with multidimensional arrays.
*
* @param string|array $glue the string for the array to be joined with or
* the array itself if $array is null
* @param array|null $array array to implode or null if array is provided as
* first parameter.
* @return string imploded array
* @throws \yii\base\InvalidParamException
@bizley
bizley / timezones.php
Last active August 29, 2015 14:17
Timezones supported by PHP
<?php
return [
'Africa/Abidjan',
'Africa/Accra',
'Africa/Addis_Ababa',
'Africa/Algiers',
'Africa/Asmara',
'Africa/Asmera',
'Africa/Bamako',
@bizley
bizley / CsNumberValidator.php
Created February 17, 2015 20:31
Yii 1.1 number validator that allows comma before decimals.
<?php
/**
* CsNumberValidator class file.
* @copyright 2014 Paweł Bizley Brzozowski
*/
/**
* CsNumberValidator is the same as CNumberValidator but allows comma instead of dot before decimals.
* So now 123,45 is valid number.
@bizley
bizley / polish-countries.php
Last active August 29, 2015 14:07
Polish names of countries of the world (ISO 3166-1 alfa-2)
<?php
// ISO 3166-1 alfa-2
// Polish names of countries of the world
// Polskie nazwy krajów świata
$countries = [
'AF' => 'Afganistan',
'AL' => 'Albania',
'DZ' => 'Algieria',
'AD' => 'Andora',
'AO' => 'Angola',
@bizley
bizley / yii-index.php
Created September 2, 2014 11:23
Yii 1.1 index.php file with output buffering
<?php
$yii = dirname(__FILE__) . '/framework/yii.php';
$config = dirname(__FILE__) . '/protected/config/main.php';
if (isset($_SERVER['REMOTE_ADDR']) && in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1'))) {
defined('YII_DEBUG') or define('YII_DEBUG', true);
ini_set('display_errors', 'on');
error_reporting(E_ALL);
}