Skip to content

Instantly share code, notes, and snippets.

View srinathweb's full-sized avatar

srinath madusanka srinathweb

View GitHub Profile
@srinathweb
srinathweb / twig
Created September 30, 2015 04:18
twig
http://stackoverflow.com/questions/9842342/building-a-site-with-twig-php-template-engine
If you're using several PHP files then it's wise to create template renderer class, which will bootstrap Twig classes, set options and take care of finding and rendering requested templates:
<?php
// Use correct path to Twig's autoloader file
require_once '/path/to/lib/Twig/Autoloader.php';
// Twig's autoloader will take care of loading required classes
Twig_Autoloader::register();
@srinathweb
srinathweb / responsive background
Created September 28, 2015 09:03
responsive background
background-image:url('../images/bg.png');
background-repeat:no-repeat;
background-size:contain;
background-position:center;
@srinathweb
srinathweb / refresh
Created September 17, 2015 06:34
refresh page
$.ajax({
url: "",
context: document.body,
success: function(s,x){
$(this).html(s);
}
});
@srinathweb
srinathweb / format number javascript
Created September 15, 2015 07:39
format number javascript
Works on all browsers, this is all you need.
function commaSeparateNumber(val){
while (/(\d+)(\d{3})/.test(val.toString())){
val = val.toString().replace(/(\d+)(\d{3})/, '$1'+','+'$2');
}
return val;
}
UTF8 w/o BOM
@srinathweb
srinathweb / most important magento
Created August 31, 2015 04:51
most important magento
http://www.opensourceforwebtechnologies.com/category/magento-theme/
http://www.opensourceforwebtechnologies.com/category/magento-theme/
@srinathweb
srinathweb / magento quering
Created August 28, 2015 11:30
magento quering
http://fishpig.co.uk/magento/tutorials/direct-sql-queries/
Yes you can run direct sql queries within Magento, the best way to do this is to use the read write resource. You can insatiate it with:
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$writeConnection = $resource->getConnection('core_write');
To run a select you can do something like this:
@srinathweb
srinathweb / use for creating color swichers
Created August 25, 2015 05:06
use for creating color swichers
http://stackoverflow.com/questions/16352864/how-to-display-image-in-place-of-checkbox
http://jsfiddle.net/pKM3x/
@srinathweb
srinathweb / use for development product attributr
Created August 21, 2015 04:18
use for development product attributr
http://fredibach.ch/jquery-plugins/tabselect.php
@srinathweb
srinathweb / magento color switch
Last active August 29, 2015 14:27
magento color switch
https://www.bemaged.com/en/blog/use-magento-swatches-in-custom-theme/
http://magento.stackexchange.com/questions/45948/how-to-use-magento-1-9-1-0-configurable-swatches-in-default-package-theme-or-a