Skip to content

Instantly share code, notes, and snippets.

View steppefox's full-sized avatar
🦥

Eldar Amantay steppefox

🦥
View GitHub Profile
@steppefox
steppefox / git_gitignore.text
Created November 14, 2013 10:56
GIT gitignore file
/upload/*
/assets/*
/protected/runtime/*
/themes/classic/views/
/protected/framework/
/public/image-content/*
*.tar.gz
*.sql
*config.local.php
!dump.tar.gz
@steppefox
steppefox / mssql_convert.md
Created November 13, 2013 06:04
MSSQL - fix for bug, when DB sends you cutted string (253-255 characters) from text field

Somehow the datatype is "char", which apparently is limited to 255 characters. BUT the DB is storing more than 255 characters.

Converting the field to TEXT works perfectly for some reason.

SELECT CONVERT(TEXT,fld_name) FROM TABLE_NAME

answered Jun 2 '10 at 21:30

Derek Adair

@steppefox
steppefox / js_parse_links.js
Created November 11, 2013 20:02
JS parse links snippet
@steppefox
steppefox / php_link_list.md
Created November 11, 2013 05:07
PHP List of links for PHP development
@steppefox
steppefox / yii_recursive_category_list.php
Created November 4, 2013 11:31
Yii snippet for recursive finding categories
function findCatalogCategory($arr=array(),$id=0,$s=''){
$ms=CatalogCategory::model()->findAll(array('condition'=>'`parent_id`='.$id,'order'=>'title','select'=>array('id','title')));
foreach ($ms as $m){
$arr[]=array('title'=>$s.$m->title,'id'=>$m->id);
if(CatalogCategory::model()->count(array('condition'=> '`parent_id`='.$m->id,'order'=>'title','select'=>array('id','title')))>0){
$arr=findCatalogCategory($arr,$m->id,($s.$m->title.' - '));
}
}
return $arr;
}
@steppefox
steppefox / yii_relations_managment.php
Created November 4, 2013 08:08
Yii relations managment (with new throught option)
public function relations()
{
return array(
'roles'=>array(self::HAS_MANY,'Role','group_id'),
'users'=>array(self::HAS_MANY,'User',array('user_id'=>'id'),'through'=>'roles'),
'comments'=>array(self::HAS_MANY,'Comment',array('id'=>'user_id'),'through'=>'users'),
);
}
@steppefox
steppefox / yii_password_managment.php
Created November 4, 2013 08:08
Yii password managment
$hash = CPasswordHelper::hashPassword($password);
CPasswordHelper::verifyPassword($password, $hash);
@steppefox
steppefox / yii_validators_list.md
Created November 4, 2013 08:07
Yii list of some fast validators

**** Validators ****

array('name','match','pattern' => '/^[a-zA-Z\s]+$/','message' => 'Только английские буквы'),
array('name','filter', 'filter'=>'strtolower'),
array('image','file','allowEmpty'=>true,'maxFiles'=>10,'types'=>'png,jpg,jpeg'),
array('text','filter','filter'=>array($obj=new CHtmlPurifier(),'purify')),

**** Own validator ****

public function passwordStrength($attribute,$params)
@steppefox
steppefox / yii_cookie_managment.php
Created November 4, 2013 07:56
YII cookie managment