Jquer slug option
Posted by mahamuddhk in Jquery Plugins on May 27, 2012
$(“#Restaurant_Name”).keyup(function(){
var Text = $(this).val();
Text = Text.toLowerCase();
Text = Text.replace(/[^a-zA-Z0-9]+/g,’-');
$(“#Restaurant_Slug”).val(Text);
});
Git log
Posted by mahamuddhk in Git on May 22, 2012
Git log check from date(since) to date(before)
$git log –author=’Mahmud Hasan’ –since=”yyyy-mm-dd” –before=”yyyy-mm-dd”
Watermark Image
Posted by mahamuddhk in PHP Tools on May 21, 2012
function watermarkImage ($SourceFile, $WaterMarkText, $DestinationFile) {
list($width, $height) = getimagesize($SourceFile);
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($SourceFile);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width, $height);
$black = imagecolorallocate($image_p, 0, 0, 0);
$font = ‘arial.ttf’;
$font_size = 15;
$grey= imagecolorallocate($image_p, 128, 128, 128);
imagettftext($image_p, $font_size, 0, 11, 21, $grey, $font, $WaterMarkText);
}
Image Overlap
Posted by mahamuddhk in PHP Tools on May 21, 2012
>?php
$myImage = imagecreatefromjpeg(‘moegie.jpg’);
$myCopyright = imagecreatefrompng(‘copyright.png’);
$destwidth = Imagesx ($myImage);
$destHeight = imagesy ($myImage);
$srcWidth = imagesx($myCopyright);
$srcHeight = imagesy ($myCopyright);
$destX = ($destWidth – $srcWidth) / 2;
$destY = ($destHeight – $srcHeight) / 2;
imagecopy($my Image, $myCopyright, $destX, $destY, 0, 0, $srcWidth,$srcHeight);
? <
Tiny Emc editor
Posted by mahamuddhk in Jquery Plugins on May 21, 2012
data = data+field.name+”=”+tinyMCE.getInstanceById(‘description’).getContent({format: “html”})+”&”;
MySql dba
Posted by mahamuddhk in MySQL Command on April 28, 2012
1. Dba backup in mysql linux
mysql -u root -p******* db_name<ip_location.sql
Yii Class Reference
Posted by mahamuddhk in Yii on February 19, 2012
1
//Default Yii jquery registration
Yii::app()->clientScript->registerCoreScript(‘jquery’);
// Java Script funcion add
if(!Yii::app()->clientScript->isScriptRegistered(“defaultVariable”))
{
Yii::app()->clientScript->registerScript(
‘defaultVariable’,
‘
if(window.location.hash != “”)
{
window.location = window.location.hash.replace(“#”, “”);
}
$(“#mainmenu li a”).click(function(event){
event.preventDefault();
var url = $(this).attr(“href”);
$.ajax({
type : “POST”,
async : false,
url : url,
success : function(response){
window.location.hash = url;
$(“#content”).html(response);
}
});
});
if(window.location.hash != “”)
{
console.log(window.location.hash);
}
‘,
CClientScript::POS_HEAD
);
}
// Check ajax request
if(Yii::app()->request->isAjaxRequest)
{
$this->renderPartial(‘login’,array(‘model’=>$model));
return;
}
2. Modules assets folder link add
public $assetsUrl;
public $defaultController = ‘Personal’;
// import the module-level models and components
$this->setImport(array(
‘profile.models.*’,
‘profile.components.*’,
));
Yii::app()->getClientScript()->registerCSSFile($this->assetsUrl . ‘/css/facebook.alert.css’);
Yii::app()->getClientScript()->registerScriptFile($this->assetsUrl . ‘/js/facebook.alert.js’);
3. Session set (UserIdentity component)
$this->setState(‘firstName’, $user->first_name);
$this->setState(‘lastName’, $user->last_name);
4. Wiget call in view file
//view folder call wiget
$this->widget(‘profile.components.widgets.sections.profileSection’,array());
// view file call partial view files
$this->renderPartial(“application.modules.profile.views.personal._basic”,$info);
5.
// CArrayDataProvider
$contactdata[] = array(“contact_id” => $id["contact_id"], ‘contact_meta’ => $respectiveMeta);
$dataProvider = new CArrayDataProvider($contactdata, array(‘keyField’ => ‘contact_id’, ‘pagination’ => array(‘pageSize’ => 5)));
$this->render(‘addContact’, array(
‘dataProvider’ => $dataProvider,
));
//call view file addContact.php
$this->widget(‘zii.widgets.CListView’, array(
‘dataProvider’=>$dataProvider,
‘itemView’=>’_view’,
));
// _view.php
print ”
";
print_r($data);6 . Url link
echo $this->createUrl("site/contactAdd");
echo Yii::app()->request->baseUrl;
7. Jquery hash function
if(window.location.hash !="")
{
$(".content-body").empty();
var url = window.location.hash.replace("#","");
window.location = url;var checkUrl = url.search("personal");
if(checkUrl!=-1)
window.location = url;else
{
$.get(url, null, function(response){
$(".content-body").empty();
$(".content-body").html(response);
});
}}
8. Memcache
http://www.yiiframework.com/wiki/17/how-to-make-use-of-a-fragment-cache/
http://www.webdeveloperjuice.com/2010/01/25/10-baby-steps-to-install-memcached-server-and-access-it-with-php/
In config main.php file
'params'=>array(
'cache-key-prefix'=>'project_');// Component array
'cache'=>array(
'class'=>'CMemCache',
'servers'=>array(
'main' => array(
'host'=>'127.0.0.1',
'port'=>11211,
'weight'=>60,
),
),
),// In controller
Yii::app()->cache->keyPrefix = Yii::app()->params['cache-key-prefix'];
$data['background'] = Yii::app()->cache->get('bg');
if(!$data['background'])
{
$sql_background = "SELECT * FROM background ORDER BY display_order,id";
$data['background'] = Yii::app()->db->createCommand($sql_background)->queryAll();
Yii::app()->cache->set('bg', $data['background']);
}
DAO Command
Posted by mahamuddhk in Yii on February 18, 2012
Yii::app()->db->createCommand($sql)->execute() // execute the non-query SQL
Yii::app()->db->createCommand($sql)->query() //execute a query SQL
Yii::app()->db->createCommand($sql)->queryAll() //query and return all rows of result
Yii::app()->db->createCommand($sql)->queryRow() // query and the first row of result
Yii::app()->db->createCommand($sql)->queryColumn() // query and return the first column of result
Git Basic Command
Posted by mahamuddhk in Git on February 18, 2012
# mkdir testGit
# cd testGit/
# git init –bare
# cd /var/www/
# git clone ~/Desktop/testGit
# cd testGit/
# ls -la
# touch a
# ls -la
# git add a
# git commit -m “file from www”
# git push
# git push origin master
# git branch
// As a client clone server Pc
$ cd /var/www/
$ git clone ssh://uidev@folsom.evoknow.com:51859/var/data/foslom/projects/quickpitchapp quickpitchapp
$ git commit -m”Added one line in default controller”
$ git pull origin master
$ git add .
$ git commit -m”Added one line again”
git push origin master
git config –bool core.bare true
git push origin master