Skip to content

Instantly share code, notes, and snippets.

View miguelbalparda's full-sized avatar
🏠
Working from home

Miguel Balparda miguelbalparda

🏠
Working from home
View GitHub Profile
@miguelbalparda
miguelbalparda / gist:6426127
Created September 3, 2013 16:23
Google+ Auth for Google apps
<?php
require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_PlusService.php';
require_once 'google-api-php-client/src/contrib/Google_Oauth2Service.php';
// Set your cached access token. Remember to replace $_SESSION with a
// real database or memcached.
session_start();
$client = new Google_Client();
@miguelbalparda
miguelbalparda / gist:8221903
Last active January 2, 2016 00:09
Change store by location - Magento
$ip = $_SERVER["REMOTE_ADDR"];//cant use helper, not loaded yet
$location = file_get_contents('http://api.ipinfodb.com/v3/ip-city/?key=<api_key>&format=json&ip='.$ip.'');
$location = json_decode($location);
$country = $location->countryCode;
if(strcmp($country,'CA') == 0) {
$mageRunType = 'store';
$mageRunCode = 'en_ca';
@miguelbalparda
miguelbalparda / gist:8224017
Created January 2, 2014 18:30
Magento rewrite vis mysql console
mysql> CREATE table temporary_table AS SELECT * FROM core_url_rewrite;
mysql> UPDATE temporary_table SET url_rewrite_id = NULL;
mysql> UPDATE temporary_table SET store_id = 4; //set the store_id you need to
mysql> UPDATE temporary_table SET id_path = UUID(); //create a unique id_path
mysql> insert ignore into core_url_rewrite select * from temporary_table; //insert the new records ignoring the ones with conflicts
<?php
// Import coupon codes
// Thanks go out to Marius Strajeru
// Original URL: http://marius-strajeru.blogspot.nl/2010/04/create-bulk-discount-rules.html
ini_set('memory_limit', '-1');
require 'app/Mage.php';
Mage::app();
// Import CSV from ViArt format:
#!/usr/bin/env python2
# Quick and dirty demonstration of CVE-2014-0160 by Jared Stafford ([email protected])
# The author disclaims copyright to this source code.
import sys
import struct
import socket
import time
import select
@miguelbalparda
miguelbalparda / gist:b57a47a010a5995bc44d
Last active August 29, 2015 14:16
Check for global/crypt/key in Magento
find . -path './app/code/core' -prune -o -iname '*php' \! -type d -print0 | xargs -0 grep -il "global/crypt/key"
SELECT email FROM customer_entity as ce JOIN newsletter_subscriber as ns ON ns.subscriber_email = ce.email AND ns.subscriber_status = 1 JOIN sales_flat_order as sfo ON sfo.customer_id = ce.entity_id JOIN sales_flat_order_item as sfoi ON sfo.entity_id = sfoi.order_id JOIN catalog_product_entity as cpe ON cpe.entity_id = sfoi.product_id WHERE cpe.sku !='' group by ce.email;
<?php
/*
If your products have been deleted but not your media gallery images you
can use the following SQL statement to remove these dormant records.
Please make sure you backup your installation and database before running this
SQL statement. It has been used on Mage 1.8.1 system:
DELETE `img` FROM `catalog_product_entity_media_gallery` img
@miguelbalparda
miguelbalparda / gist:ec670c6109c719ee2e53
Created November 6, 2015 18:57 — forked from sprankhub/gist:a386a2969ca7cc6f6552
Fish Shell Autocompletion for the Magento 2 Shell Script
# Installation:
# Copy to ~/.config/fish/completions/magento.fish
# Open new or restart existing shell session
# Commands based on Magento 2.0.0-rc and the command
# bin/magento --raw --no-ansi list
# It is a static list since you probably do not have the magento shell script
# in your path.
complete -f -c magento -a --help;
complete -f -c magento -a -h;
** SIEGE 3.0.6
** Preparing 500 concurrent users for battle.
The server is now under siege...
Lifting the server siege...      done.
Transactions:                  39116 hits
Availability:                 100.00 %
Elapsed time:                  59.44 secs
Data transferred:             541.05 MB
Response time:                  0.26 secs