Skip to content

Instantly share code, notes, and snippets.

View steverobbins's full-sized avatar

Steve Robbins steverobbins

View GitHub Profile
select p1.sku `parent sku`, group_concat(p2.sku) `associated skus`, lt.code `type`
from catalog_product_link l
inner join catalog_product_entity p1 on p1.entity_id = l.product_id
inner join catalog_product_entity p2 on p2.entity_id = l.linked_product_id
inner join catalog_product_link_type lt on l.link_type_id = lt.link_type_id
group by l.product_id
/var/www/example.com/shared/var/log/*.log {
rotate 5
daily
nocompress
missingok
notifempty
nocreate
}
grep -l community app/etc/modules/* | xargs perl -pi -e 's/true/false/g'
select
`Time Period`,
round(avg(num), 1) `Average Number of Orders`
from (
select
date_format(date_sub(o.created_at, interval 8 hour), "%l:00 - %l:59 %p PST") `Time Period`,
count(*) num,
date_format(date_sub(o.created_at, interval 8 hour), "%H") sort
from sales_flat_order o
where o.created_at > '2016-01-01 00:00:00'
insert into core_config_data (`scope`, scope_id, `path`, `value`) values('default', 0, 'dev/log/active', '1') on duplicate key update `value`='1';
insert into core_config_data (`scope`, scope_id, `path`, `value`) values('default', 0, 'admin/security/session_cookie_lifetime', '360000') on duplicate key update `value`='360000';
insert into core_config_data (`scope`, scope_id, `path`, `value`) values('default', 0, 'web/cookie/cookie_lifetime', '360000') on duplicate key update `value`='360000';
insert into core_config_data (`scope`, scope_id, `path`, `value`) values('default', 0, 'admin/security/password_is_forced', '0') on duplicate key update `value`='0';
insert into core_config_data (`scope`, scope_id, `path`, `value`) values('default', 0, 'admin/security/password_is_forced', '0') on duplicate key update `value`='0';
update core_config_data set value = 'http://project.192.168.50.100.xip.io/' where path like '%base_url';
update core_config_data set value = ''
curl -o n98-magerun.phar https://raw.githubusercontent.com/netz98/n98-magerun/master/n98-magerun.phar
chmod +x n98-magerun.phar
./n98-magerun.phar --root-dir=/var/www/example.com/current/ admin:user:create username username@example.com Password Steve Robbins Administrators
#!/bin/bash
################################################################################
# FUNCTIONS
################################################################################
# 1. Check required system tools
_check_installed_tools() {
local missed=""
SET @DATABASE = 'prod';
SELECT CONCAT(table_schema, '.', table_name),
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(index_length / data_length, 2) idxfrac
FROM information_schema.TABLES
WHERE `information_schema`.TABLES.table_schema = @DATABASE
<?php
include 'app/Mage.php';
Mage::app('admin', 'store');
$password = substr(md5('Password' . time()), 0, 16);
$user = Mage::getModel("admin/user")
->setData(array(
'username' => 'steve',
Get-Content dump.sql | Foreach-Object { $_ -replace 'DEFINER(.*)`magento-dbuser`@`localhost`','DEFINER$1`different-user`@`different-host`' } | Set-Content new.sql