Skip to content

Instantly share code, notes, and snippets.

@victordit
victordit / calc_radius_between_two_points.php
Last active September 25, 2015 15:42
Calc the radius (distance) between two points (2 latitudes and 2 longitudes)
<?php
/**
* @return integer
* @param double $lat_from latitude
* @param double $lon_from longitude
* @param double $lat_to latitude
* @param double $lon_to longitude
* @param string $unit The format of return ('km' =>kilometers,'mts'=>meters )
*
*/
@victordit
victordit / is_serialized.php
Created September 30, 2015 00:56
Check value to find if it was serialized
<?php
/**
* Check value to find if it was serialized.
*
* If $data is not an string, then returned value will always be false.
* Serialized data is always a string.
*
* @param string $data Value to check to see if was serialized.
* @param bool $strict Optional. Whether to be strict about the end of the string. Default true.
* @return bool False if not serialized and true if it was.
<?php
const LOG = 'my.log';
/**
* @return void
* @param $var The variable passed
* @param string $label
* @param boolean $backtrace
*/
@victordit
victordit / Listing all Magento Events in a txt
Created March 31, 2016 10:31 — forked from IzyPizy/Listing all Magento Events in a txt
Not all the version look the same, so do not use lists got from the web. A simple cli command that lists all the events included local & community extension
grep -rin -B2 -A2 "Mage::dispatchEvent" pathToMagentoRoot/app/* > events.txt
@victordit
victordit / magento_get_all_super_attributes_from_simple_products.sql
Last active April 21, 2016 13:21
A query for extract a list of sku and variants
SELECT
-- cpe.entity_id as product_id,
cpe.sku,
cpsal.value as variant_name,
eaov.value as variant_default,
eaov_it.value as variant_it,
eaov_en.value as variant_en,
eaov_de.value as variant_de,
eaov_fr.value as variant_fr,
-- Search products descriptions
SELECT
cpe.entity_id,
cpe.sku,
cs.name as store,
cpet_d.value as description,
cpet_sd.value as short_description
FROM `catalog_product_entity` as cpe
<?php
/**
* A simple fix for a shell execution on preg_match('/[0-9]\.[0-9]+\.[0-9]+/', shell_exec('mysql -V'), $version);
* The only edit that was done is that shell_exec('mysql -V') was changed to mysql_get_server_info() because not all
* systems have shell access. XAMPP, WAMP, or any Windows system might not have this type of access. mysql_get_server_info()
* is easier to use because it pulls the MySQL version from phpinfo() and is compatible with all Operating Systems.
* @link http://www.magentocommerce.com/knowledge-base/entry/how-do-i-know-if-my-server-is-compatible-with-magento
* @author Magento Inc.
*/
# Magento exclude core
.htaccess.sample
.modgit/
.modman/
app/code/community/Phoenix/Moneybookers/
app/code/community/Cm/RedisSession/
app/code/core/
app/design/adminhtml/default/default/
app/design/frontend/base/
app/design/frontend/rwd/
<?php
/**
* @return string
* @param string $url
* @param array $params
*/
public function removeQueryString($url,$params=array())
{
if(count($params)){
foreach ($params as $value) {
<?php
/**
* @return void
* @param $var The variable passed
* @param string $module The name of module
* @param integer limit The limit for each
*/
public function log($var,$module,$limit =2)
{