Skip to content

Instantly share code, notes, and snippets.

View molotovbliss's full-sized avatar
⚗️
Code, Eat, Sleep++;

Jared molotovbliss

⚗️
Code, Eat, Sleep++;
  • DFW, Texas
View GitHub Profile
@molotovbliss
molotovbliss / magento-db-reset-sql-scripts.sql
Created March 23, 2016 18:51
Magento DB reset SQL Scripts
# original source: http://www.redmonkeygoo.com/labs/lab-1-magento-db-reset-scripts/
#-- Magento 1.7.0.0 SQL Table Resets
#-- On initial install Magento has 335 tables
#SET FOREIGN_KEY_CHECKS=0;
#SET FOREIGN_KEY_CHECKS=1;
SET FOREIGN_KEY_CHECKS=0;
@molotovbliss
molotovbliss / mage.jpg.sh
Created March 29, 2016 19:54
Scan for Mage.jpg Malware Derivative
# Locate malware storing credit card info in images, original source:
# http://blog.foregenix.com/magento-malware-alert-mage.jpg-malware-derivative
find . -type f -exec egrep -Hl "md5\(md5\(microtime\(\)\)\.rand\(\)\)|\@file_put_contents\([^,]+,'JPEG-1\.1'\.base64_encode\([^\)]+\),FILE_APPEND\)" {} \;
@molotovbliss
molotovbliss / autoselectitems.phtml
Last active March 30, 2016 19:01
Auto select first items on Configurables
<script type="text/javascript">
var spConfig = new Product.Config(<?php echo $_jsonConfig ?>);
// auto select first selections (and remove Choose text...)
spConfig.setInitialState = function(dropdown_id) {
var dropdown = $(dropdown_id);
dropdown[0].remove();
for(index = 0; index < dropdown.length; index++) {
if(dropdown[index].value != "") {
/**
* Get Allowed Countries
*/
protected function _getCountryOptions() {
$options = false;
$useCache = Mage::app()->useCache('config');
if ($useCache) {
$cacheId = 'DIRECTORY_COUNTRY_SELECT_STORE_' . Mage::app()->getStore()->getCode();
$cacheTags = array('config');
@molotovbliss
molotovbliss / POST-2-REST.php
Last active April 10, 2016 05:41
POST to REST API with file_post_contents
<?php
/**
* POST data to a REST API via file_post_contents with HTTP user/password support
* Author: [email protected]
*
* @param $url string URL path to REST API HTTP server request
* @param $data array Values to POST along side request
* @param $debug boolean Display debug data at end of request/response
* @param $username string HTTP username
* @param $password string HTTP password
@molotovbliss
molotovbliss / gist:aa3c769171624f1640dcf2c8503b2ecc
Last active April 19, 2016 15:24
large entropy/hash for PHP Sessions.
ini_set('session.hash_function', 'sha512');
ini_set('session.hash_bits_per_character', 6);
ini_set('session.entropy_file', '/dev/urandom');
ini_set('session.entropy_length', 128);
# example sesion ID: K7ZvnlbRth5JbbJIRIDWdljiKHnP2fRrOVpCMxSbp9rO4OWzynraCon3O-Gfu9beuy2YGHEBpE14uvMzOfVvj3
@molotovbliss
molotovbliss / magento-isTableExists.php
Created April 21, 2016 07:25
How to check if a table already exists in Magento. Useful in setup scripts.
<?php
zend_debug::dump(
Mage::getSingleton('core/resource')
->getConnection('core_write')
->isTableExists(trim($this->getTable('namespace/module'),'`'))
);
@molotovbliss
molotovbliss / createCmsBlock.php
Last active April 21, 2016 08:22
Create CMS Blocks in Magento.
<?php
// Define your data here:
$blockId = "customblock_id";
$blockTitle = " CMS BLOCK TITLE ";
// Using <<<HTML allows for easy copy/pasta of HTML data
$content = <<<HTML
<a href="#">Test</a>
HTML;
@molotovbliss
molotovbliss / force-acl.php
Created April 21, 2016 08:28
Unset Admin Session to Force ACL refresh on Magento module installs
<?php
$adminSession = Mage::getSingleton('admin/session');
$adminSession->unsetAll();
$adminSession->getCookie()->delete($adminSession->getSessionName());
@molotovbliss
molotovbliss / betterindexer.php
Last active May 1, 2017 20:37
Magento: only reindex invalidated indexes shell/indexer.php replacement
<?php
/**
* Add the parameter "reindexallrequired" to only index the indexers
* that are in need of processing to avoid doing full reindexes
* that disregard the state of the index as indexer.php does
*
* Usage:
* php shell/betterindexer.php reindexallrequired
*
* http://magento.stackexchange.com/a/62272/69