Tuesday, April 6, 2021

The Top 3 Best Torrent Sites Ever lived

I hope you know what torrent means otherwise this post is not for you at all, you better visit Dominoz and have Pizzas. I have been a fan of torrent sites from long time. I have used many torrent sites before btjunkie and isohunt being my favorite, of course before they were taken down in 2013.  !!!Cheers!!! Somehow isohunt is back again. After a deep overview i have rated the best of 2014.
  1. Isohunt.to : The longtime Champion Isohunt is reborn! Its back again after being shut down on October 17, 2013 by the MPAA, Isohunt has been restarted with a new domain name in a new country.  Please support this longtime champion of P2P file sharing!
  2. Demonoid : This is a private membership community and you need little efforts or luck to be part of it, It has restarted itself at new domain name Demonoid.ph. It has been was a very popular and trusted place to get files and stay informed on which torrents to avoid.  Now we need to see if Demonoid can regain the same users confidence at its new server location.
  3. VCDQ.com :  This torrent site isn't technically a torrent search site but,  it actually leads in providing verified torrents.  They have a good number of serious users group who confirms that torrents do indeed exist for thousands of titles,  specially brand new movie releases. You can use CVDQ to search and confirm if a title is available, then just search the same title as it is to other torrent search engine like Isohunt.to. This will definitely save you from FAKE torrents.

Setting up Google Map V3 with JQuery

Gmap 3   gmap3 is a jquery plugin for google map api version3(V3) Include the google script in your page
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false"></script>
then gmap3 plugin (download it from Download Gmap3.js)
<script type="text/javascript" src="gmap3.min.js"></script>
once dom is ready you can use gmap3,
$(document).ready(function(){
$("#example").gmap3();
});
  dont forget to define height & width of div you are using to&nbsp;show map something&nbsp;like
<div style="height:350px; width:600px" id="example"></div>

Multi-store capabilities for Magento Newsletter

popup_form Magento seems to not to be perfect at times, though i believe its GREAT. Recently i was working on a multistore project, i launched first of its store successfully. While testing Newsletter functionality for the Second store i got to know that Magento has an issue with its multistore capabilities. I digged into it and found that each time a user subscribes newsletter from a new or different store in the same setup with same Email IDthe old entry vanishes and new entry is overwritten to it. The new entry was overwriting Store Id to newsletter table for the same email address. That means a single Email ID can be subscribed to only one store at a time and that was definitely a blunder. The solution is simple. Here you can create a new module or just overwrite Newsletter Resource Model class into your custom Namespace under local codepool. You need to override  function loadByEmail and loadByCustomer from  Mage_Newsletter_Model_Mysql4_Subscribe class.
/**
 * Resource Model
 * @author Swapnil Kene
 * FILE Namespace/Newsletter/Model/Resource/Subscriber.php
 */
class Namespace_Newsletter_Model_Resource_Subscriber extends Mage_Newsletter_Model_Mysql4_Subscriber
{
    /**
     * Load subscriber from DB by email
     *
     * @param string $subscriberEmail
     * @return array
     */
    public function loadByEmail($subscriberEmail)
    {
        /** @var $customerSession Mage_Customer_Model_Session */
        $customerSession = Mage::getSingleton('customer/session');
        $ownerId = Mage::getModel('customer/customer')
            ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
            ->loadByEmail($subscriberEmail)
            ->getId();
 
        $storeId = $customerSession->isLoggedIn() && $ownerId == $customerSession->getId()
            ? $customerSession->getCustomer()->getStoreId()
            : Mage::app()->getStore()->getId();
 
        $select = $this->_read->select()
            ->from($this->getMainTable())
            ->where('subscriber_email=:subscriber_email')
            ->where('store_id=:store_id'); // Add store ID for newsletters
 
        $result = $this->_read->fetchRow($select, array(
            'subscriber_email'  => $subscriberEmail,
            'store_id'          => $storeId
        ));
 
        if (!$result) {
            return array();
        }
 
        return $result;
    }
 
    /**
     * Load subscriber by customer
     *
     * @param Mage_Customer_Model_Customer $customer
     * @return array
     */
    public function loadByCustomer(Mage_Customer_Model_Customer $customer)
    {
        $select = $this->_read->select()
            ->from($this->getMainTable())
            ->where('customer_id=:customer_id')
            ->where('store_id=:store_id');
 
        $result = $this->_read->fetchRow($select, array(
            'customer_id'   => $customer->getId(),
            'store_id'      => $customer->getStoreId()
        ));
 
        if ($result) {
            return $result;
        }
 
        $select = $this->_read->select()
            ->from($this->getMainTable())
            ->where('subscriber_email=:subscriber_email')
            ->where('store_id=:store_id');
 
        $result = $this->_read->fetchRow($select, array(
            'subscriber_email'  => $customer->getEmail(),
            'store_id'          => $customer->getStoreId()
        ));
 
        if ($result) {
            return $result;
        }
 
        return array();
    }
}

Performance boost using DNS Prefetching

Despite anchor tags having HREF attributes which lead to other host names, browsers do not execute DNS lookups on those domains. Content prefetching can be invaluable in speeding up your websites, but did you know that you can also implement DNS prefetching? It's as easy as simple LINK element:   Of many things one of the step in boosting website performance in a way by improving user experience is using DNS Prefetching. For an example if you have some or many links pointing to other domains HREF attribute doesn't help browsers in executing DNS lookups on those domains. By using Content Prefetching helps speeding up your website but by DNS Prefetching browsers executes DNS lookups on those domains. Its very simple as adding a LINK tag, look at the below code
<link rel="dns-prefetch" href="//somehost.tld" />
This is useful when your website links to related host names. Twitter for example uses two DNS Prefetches
<link rel="dns-prefetch" href="https://si0.twimg.com" />
<link rel="dns-prefetch" href="https://api.twitter.com" />
Its up to you to decide will it help in your case. You can refer more details at http://www.chromium.org/developers/design-documents/dns-prefetching

Download directly Magento 1 Community free extensions

Sometime you dont want to install Magento's community extensions through magento connect, instead need to download files. Here is a simple way to download any free extension available on magento connect. You just need to get the extension key from Magento connect and follow the below link http://freegento.com/ddl-magento-extension.php

Magento Get Url , Get Base Url , Skin Url , Media Url , Js Url , Store Url and Current Url

Magento Get Url in block / phtml  files

1. Get Base Url :
Mage::getBaseUrl();
2. Get Skin Url :
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);
(a) Unsecure Skin Url :
$this->getSkinUrl('images/imagename.jpg');
(b) Secure Skin Url :
$this->getSkinUrl('images/imagename.gif', array('_secure'=>true));
3. Get Media Url :
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
4. Get Js Url :
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);
5. Get Store Url :
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);

Or Simply

Mage::getBaseUrl();
6. Get Current Url
Mage::helper('core/url')->getCurrentUrl();

Get Url in cms pages or static blocks. Magento parses pre specified structures to actual URLs before rendering pages.

1. Get Base Url :
{{store url=""}}
2. Get Skin Url :
{{skin url='images/media.jpg'}}
3. Get Media Url :
{{media url='/media.jpg'}}
4. Get Store Url :
{{store url='page.html'}}
5. Get secure Store Url :
 {{store url="page.html" _secure="true"}}

Sunday, June 5, 2011

mysql database dump using php

Sometimes application needs database backup or rather dump on a regular interval or on request.

So we need a faster and easy way to create mysql dump and also compress those database files to save disk space.

 

This could be a very easy if we use some shell commands through php and create mysql dump. See below how we could achieve this.

 

 

<?php

//Database details

$dbhost = "localhost";

$dbname = "bear44_visitusa";

$dbuser = "bear44_visit";

$dbpwd  = "H8JKjfhyur&*HGrjy";

 

 

 

//List of tables you want to dump separated by single space

$tbl = "getaways_leftmenu getaways_seourl getaways_cmspages";

 

//execute command

exec("mysqldump -h $dbhost -u $dbuser -p\"$dbpwd\" $dbname $tbl > sqlfilename.sql");

 

 

//stores location of current directory

$dir = dirname(realpath(__FILE__));

 

 

 

//command to compress previously created sql file, also gzip -9 states to remove original sql file 

$zip = "gzip -9 $dir/sqlfilename.sql";

 

//execute command

exec($zip);

 

?>
   

 

thats it and you have zipped version of your dump file and the original sql file is automatically removed