Skip to content

Instantly share code, notes, and snippets.

@btray77
btray77 / xml2json.js
Last active April 15, 2021 23:56
RegEX to parse XML to JSON
// Original from: http://killzonekid.com/worlds-smallest-fastest-xml-to-json-javascript-converter/
// Thanks to Loamhoof for helping get this working!
// http://stackoverflow.com/questions/15675352/regex-convert-xml-to-json/15680000
//Load XML into XML variable
var regex = /(<\w+[^<]*?)\s+([\w-]+)="([^"]+)">/;
while (xml.match(regex)) xml = xml.replace(regex, '<$2>$3</$2>$1>');
xml = xml.replace(/\s/g, ' ').
############################################################
# locking down the ssh system next.
# see http://www.howtogeek.com/howto/linux/security-tip-disable-root-ssh-login-on-linux/
useradd YOURNAME
passwd YOURNAME
############################################################
# some good things in this repo
# @see http://fedoraproject.org/wiki/EPEL
/* adjust body when menu is open */
body.slide-active {
overflow-x: hidden
}
/*first child of #page-content so it doesn't shift around*/
.no-margin-top {
margin-top: 0px!important
}
/*wrap the entire page content but not nav inside this div if not a fixed top, don't add any top padding */
#page-content {
@btray77
btray77 / Observer.php
Last active August 29, 2015 14:04
Magento CRON set Tax Class ID
<?php
// app/code/local/Yourname/Tax/Model/Observer.php
class YourName_Tax_Model_Observer {
public function updateTaxRates(){
$productCollection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('tax_class_id');
foreach ($productCollection as $product) {
$taxClassId = $product->getTaxClassId();
@btray77
btray77 / all_backup.sh
Created August 6, 2014 19:45
dropbox-quick-backup-script
#!/bin/bash
# SOURCE: https://www.magenx.com/server/dropbox-quick-backup-script
# USAGE: chmod +x all_backup.sh
# ./all_backup.sh
MAGENTODB=YOUR_MAGENTO_DB
PASSWORD=YOUR_MAGENTO_DB_PASS
USER=YOUR_MAGENTO_DB_USER
@btray77
btray77 / add_map.php
Last active August 29, 2015 14:08
Set Map on Magento with LSFS
<?php
/*
(C) 2014 All Rights Reserved. Brad Traynham, MIT Licensed
This file goes in the shell folder of Magento.
*/
ini_set('display_errors', 'On');
ini_set('memory_limit', '512M');
error_reporting(E_ALL);
require_once('abstract.php');
@btray77
btray77 / README.md
Last active January 16, 2016 04:02
Used make categories active or turn them off depending on if they have products in them in Magento 1.9.2.2 (other versions may work). This should be installed in your webroot/shell folder and run via a cron script as often as you wish it to run. We run it 2 times a day.

Here's an example cron. It runs at 3am/3pm daily. Only if the website is not undergoing maintenance.

0 3,15 * * * ! test -e /var/www/html/maintenance.flag && /usr/bin/php /var/www/html/shell/activeCategories.php

You could use something like this.

0 3,15 * * * /usr/bin/php /var/www/html/shell/activeCategories.php

@btray77
btray77 / -etc-nginx-conf.d-export.conf
Last active January 18, 2016 17:59
This is my current nginx configuration for magento 1.9.2.2.
# configuration file /etc/nginx/conf.d/export.conf:
location ~ /var/export {
satisfy all;
allow 1.2.3.4;
deny all;
auth_basic "Restricted";
auth_basic_user_file .htpasswd;
autoindex off;
}
@btray77
btray77 / cannotbesoldonebay.txt
Last active March 25, 2016 16:52
Supplements that cannot be sold on eBay or your will have your account suspended.
CTD Sports Noxipro Chrome Fruit Punch 292 g
Ctd Sports Noxipro Fruit Punch 216g 40 Svg
GAT JetFuel Superburn 120 ct
Hi-Tech Pharmaceuticals Lipodrene Yellow 90 tb
High Energy Labs HGH Complete 100 ct
High Energy Labs HGH Complete Raspberry Lemonade 700 g
Human Evolution Core Burner 60 ct
Human Evolution Core Burner Watermelon 30 svg
Labrada Charge Extreme Energy Booster 120 ct
Labrada For Her Fat Burner 60 ct
@btray77
btray77 / resize-images.sh
Created July 8, 2016 01:36
Resize images in a folder to a minimum size, keep aspect ratio.
#!/bin/bash
#Edit webroot to meet your needs
IFS=$'\n'
set -e
minimumWidth=1000
minimumHeight=1000
FILES=$(find /webroot/media/catalog/product/ \( -name cache -prune \) -o -name '*' -type f -exec file {} \; | awk -F: '{ if ($2 ~/[Ii]mage|EPS/) print $1}')