var x = 30; //minutes interval
var timesarr = []; // time array
var tt = 0; // start time
var ap = ['AM', 'PM']; // AM-PM
//Loop to increment the time and push results in times array
for (var i=0;tt<24*60; i++) {
var hh = Math.floor(tt/60); // getting hours of day in 0-24 format
var mm = (tt%60); // getting minutes of the hour in 0-55 format
timesarr[i] = ("0" + (hh % 12)).slice(-2) + ':' + ("0" + mm).slice(-2) + ' ' + ap[Math.floor(hh/12)]; // pushing data in array in [00:00 - 12:00 AM/PM format]
tt = tt + x;
}
console.log(timesarr);
Shopify, Shopify Apps, Magento, WordPress, Codeigniter, Joomla, Big Commerce | PHP
Thursday, 1 February 2018
Half hours / 15 Minutes time loop in Javascript / jQuery
Thursday, 25 January 2018
How to keep multiple values selected dropdown in magento addField (multiselect)
$filterData = $this->helper('adminhtml')->prepareFilterString($this->getRequest()->getParam('filter', false));
$fieldset->addField('warehouse', 'multiselect', array(
'label' => Mage::helper('namespace_reports')->__('Warehouse'),
'title' => Mage::helper('namespace_reports')->__('Select multiple warehouse'),
'name' => 'warehouse',
'values' => $this->_getWarehouseArr(),
'value' => isset($filterData['warehouse'][0]) ? explode(',', $filterData['warehouse'][0]) : array(),
'style' => 'height:43px'
));
Tuesday, 23 January 2018
How to set background color into transparent image Imagick PHP
ini_set('display_errors',1);
header('Content-type: image/png');
$strInputFile = 'front.png'; // transparent image
$im = new Imagick($strInputFile);
$im->setImageBackgroundColor('green');
$im = $im->flattenImages();
echo $im;exit;
Saturday, 13 January 2018
How to install custom or subdomain SSL certificate in AWS.
How to install custom or subdomain SSL certificate in AWS.
1. sudo dpkg –s openssl
2. sudo a2enmod ssl
3. sudo service apache2 restart
4. openssl req -nodes -newkey rsa:2048 -keyout myserver.key -out server.csr
1. Country Name (2 letter code) [AU]: GB
2. State or Province Name (full name) [Some-State]: Surrey
3. Locality Name (eg, city) []: London
4. Organization Name (eg, company) [Internet Widgits Pty Ltd]: Company Name Pvt Ltd
5. Organizational Unit Name (eg, section) []: IT Department
6. Common Name (eg, YOUR name) []: yourdomain.com
7. Email Address []:webmaster@yourdomain.com
8. A challenge password []:
9. An optional company name []:
5. GET Certificate files and upload to "/var/www/html/cert/" :
1. private.key - Which you have generate using step 4
2. c00d2e98b15a0818.crt - Which you get certificate 3rd party
3. gd_bundle-g2-g1.crt - Which you get chain 3rd party
6. sudo nano /etc/apache2/sites-available/default-ssl.conf
**************
**************
DocumentRoot /var/www/html
<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
*******
*******
*******
SSLCertificateFile "/var/www/html/cert/c00d2e98b15a0818.crt"
SSLCertificateKeyFile "/var/www/html/cert/private.key"
SSLCertificateChainFile "/var/www/html/cert/gd_bundle-g2-g1.crt"
*******
*******
*******
7. sudo a2ensite default-ssl.conf
8. sudo service apache2 restart
9. Check your ssl : https://www.sslshopper.com/ssl-checker.html
Tuesday, 9 January 2018
Clear configurable Swatches, Images, Flush Magento ALL Cache and cache files
ini_set('display_errors', 1);
require_once('../app/Mage.php');
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
/* Clear Cache */
try {
$allTypes = Mage::app()->useCache();
foreach($allTypes as $type => $cache) {
Mage::app()->getCacheInstance()->cleanType($type);
}
/**
* Flush cache storage
*/
Mage::dispatchEvent('adminhtml_cache_flush_all');
Mage::app()->getCacheInstance()->flush();
/**
* Flush all magento cache
*/
Mage::app()->cleanCache();
Mage::dispatchEvent('adminhtml_cache_flush_system');
} catch (Exception $e) {
Mage::logException($e->getMessage());
}
try {
/* cleanImages */
Mage::getModel('catalog/product_image')->clearCache();
Mage::dispatchEvent('clean_catalog_images_cache_after');
/* cleanSwatches */
Mage::helper('configurableswatches/productimg')->clearSwatchesCache();
Mage::dispatchEvent('clean_configurable_swatches_cache_after');
clearCstoreCacheDir('../var/cache');
echo 'Success';
} catch (Mage_Core_Exception $e) {
echo $e->getMessage();
} catch (Exception $e) {
echo Mage::helper('adminhtml')->__('An error occurred while clearing the configurable swatches image cache.');
}
function clearCstoreCacheDir($dirPath) {
if (!is_dir($dirPath)) {
throw new InvalidArgumentException("$dirPath must be a directory");
}
if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
$dirPath .= '/';
}
$files = glob($dirPath . '*', GLOB_MARK);
foreach ($files as $file) {
if (is_dir($file)) {
self::deleteDir($file);
} else {
unlink($file);
}
}
rmdir($dirPath);
}
Tuesday, 2 January 2018
How to install extensions in php 7 cent os
Install extensions in php 7 cent os follow these steps
1. curl 'https://setup.ius.io/' -o setup-ius.sh
2. sudo bash setup-ius.sh
3. sudo yum install -y mod_php70w php70w-cli php70w-mysqlnd php70w-json php70w-gd php70w-dom php70w-simplexml php70w-mcrypt php70w-intl httpd mysql-server git
Labels:
Cent,
Cent OS,
cli,
dom,
Extensions,
Git,
httpd,
install,
Intl,
JSON,
Magento 2,
Mcrypt,
mysql-server,
mysqlnd,
PHP,
PHP 7,
simplexml
Saturday, 30 December 2017
How to download and Extract Uncompress zip / gz file from URL in PHP
ini_set('display_errors', 1);
$dbname = 'db_'.date('Ymdhis').".gz";
$url = 'http://www.domainname.com/backups/bkp30122017.gz';
file_put_contents($dbname, fopen($url, 'r'));
Extract / Uncompress GZ / ZIP file
try{
//This input should be from somewhere else, hard-coded in this example
$file_name = $dbname;
// Raising this value may increase performance
$buffer_size = 4096; // read 4kb at a time
$out_file_name = str_replace('.gz', '.sql', $file_name);
// Open our files (in binary mode)
$file = gzopen($file_name, 'rb');
$out_file = fopen($out_file_name, 'wb');
// Keep repeating until the end of the input file
while (!gzeof($file)) {
// Read buffer-size bytes
// Both fwrite and gzread and binary-safe
fwrite($out_file, gzread($file, $buffer_size));
}
// Files are done, close files
fclose($out_file);
gzclose($file);
} catch (Exception $ex) {
echo $ex->getMessage();
}
Subscribe to:
Posts (Atom)