Skip to content

Instantly share code, notes, and snippets.

Avatar

Biswarup Adhikari biswarupadhikari

View GitHub Profile
@biswarupadhikari
biswarupadhikari / validate.js
Created Nov 19, 2013
Validate Version using Javascript
View validate.js
function validateVersion(version){
var pat=/^[0-9]{1,3}.[0-9]{0,3}.[0-9]{0,3}$/;
return pat.test(version)
}
Validate Version
var version="10.2.5";
if(validateVersion(version)){
@biswarupadhikari
biswarupadhikari / Model.php
Created Oct 23, 2013
Joomla Custom Server Side Va
View Model.php
/**
* Validate Data
*/
function validate($form, $data,$group=null){
$status=true;
if(!$this->EmailValidate($data['email'])){
$status=false;
}
if($status){
return $data;
@biswarupadhikari
biswarupadhikari / datetime_diff.php
Created Sep 30, 2013
Datetime difference in Hour
View datetime_diff.php
<?php
function getTimeDifference($start_time,$stop_time){ $start_time=strtotime($start_time); $stop_time=strtotime($stop_time); $seconds=$stop_time - $start_time; if($seconds > 3600 ){ $hours=floor($seconds / 3600); $seconds=$seconds % 3600; }else{ $hours='00'; } if($seconds > 60 ){ $minutes=floor($seconds / 60); $seconds=$seconds % 60; }else{ $minutes='00'; } return $hours.':'.$minutes.':'.$seconds; } echo getTimeDifference('2013-05-11 13:24:48','2013-05-12 13:59:49');
View new_gist_file
your socket is already in use. kill it and it should be resolved.fuser -k 8080/tcp for example the above code kills and frees the socket at 8080
Kill using process ID
@biswarupadhikari
biswarupadhikari / gist:6487523
Created Sep 8, 2013
Change PHPVersion Via htaccess
View gist:6487523
AddType application/x-httpd-php54 .php
AddType application/x-httpd-php53 .php
AddType application/x-httpd-php5 .php
@biswarupadhikari
biswarupadhikari / changePermission.php
Created Sep 7, 2013
Change File FolderPermission Recursively via PHP Script
View changePermission.php
<?php
$curDir=dirname(__FILE__);
exec ("find $curDir -type d -exec chmod 0755 {} +");
exec ("find $curDir -type f -exec chmod 0644 {} +");
View unzip.php
<?php
$zip = new ZipArchive;
$res = $zip->open('my-20130906-191334.zip');
if ($res === TRUE) {
$zip->extractTo(dirname(__FILE__));
$zip->close();
echo 'woot!';
} else {
echo 'doh!';
}
@biswarupadhikari
biswarupadhikari / contentreplace.py
Created Aug 12, 2013
Sublime Text :: Inser Or Replace Content
View contentreplace.py
import sublime, sublime_plugin
class ExampleCommand(sublime_plugin.TextCommand):
def run(self, edit):
for region in self.view.sel():
self.view.replace(edit, region,"Test")
@biswarupadhikari
biswarupadhikari / gist:5592381
Created May 16, 2013
Joomla : Frontend pagination pass variable values
View gist:5592381
<?php
$listOrder=$this->escape($this->state->get('list.ordering'));
$orderDirn=$this->escape($this->state->get('list.direction'));
$app =JFactory::getApplication();
$router =$app->getRouter();
$router->setVar( 'filter_order',$listOrder);
$router->setVar( 'filter_order_Dir',$orderDirn);
$router->setVar( 'view','bookings');
?>
@biswarupadhikari
biswarupadhikari / regularexpression.php
Created May 9, 2013
PHP: Regular Expression Example can be used in joomla plugin development
View regularexpression.php
<?php
$text="welcome to my blog {Twitter}google{/twitter}this ius how us follow me on {twitter}biswarupa
{/twitter} created i dont ondsfdsk dsf";
preg_match_all('/{twitter}(.*?)\{\/twitter}/is',$text,$matches);
print_r($matches);
/*
*/is i means case insesitive {twitter} or {TWiter} s whitespace or newline like {twitter}
{/twitter}
*/