Skip to content

Instantly share code, notes, and snippets.

Avatar

Steve Robbins steverobbins

View GitHub Profile
@mttjohnson
mttjohnson / dbsnapshot.sh
Last active Feb 25, 2020
MySQL DB snapshot separating tables into files for comparison purposes
View dbsnapshot.sh
#!/usr/bin/env bash
##
# Copyright © 2017 by Matt Johnson. All rights reserved
#
# Licensed under the Open Software License 3.0 (OSL-3.0)
# See included LICENSE file for full text of OSL-3.0
#
# https://github.com/mttjohnson
##
@iben12
iben12 / 1_Laravel_state-machine.md
Last active Sep 9, 2021
Laravel: State-machine on Eloquent Model
View 1_Laravel_state-machine.md

Implementing State Machine On Eloquent Model*

* Update (12.09.2017): I have improved the trait so that it can be used with objects other than Eloquent Models.

Some days ago I came across a task where I needed to implement managable state for an Eloquent model. This is a common task, actually there is a mathematical model called "Finite-state Machine". The concept is that the state machine (SM) "can be in exactly one of the finite number of states at any given time". Also changing from one state to another (called transition) depends on fulfilling the conditions defined by its configuration.

Practically this means you define each state that the SM can be in and the possible transitions. To define a transition you set the states on which the transition can be applied (initial conditions) and the only state in which the SM should be after the transition.

That's the theory, let's get to the work.

@molotovbliss
molotovbliss / betterindexer.php
Last active May 1, 2017
Magento: only reindex invalidated indexes shell/indexer.php replacement
View betterindexer.php
<?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
@piotrekkaminski
piotrekkaminski / gist:9bc45ec84028611d621e
Last active Oct 14, 2019
How to automatically download patches and release of Magento
View gist:9bc45ec84028611d621e
1) First you need to generate download token. Login to your account on magento.com and generate it in Account Settings->Downloads Access Token
2) You will need your MAGEID as well. It is shown at the top-left in your account page.
3) curl -k https://MAGEID:TOKEN@www.magentocommerce.com/products/downloads/info/help
4) Profit!
@gwillem
gwillem / magento-nginx.conf
Last active Aug 9, 2021
Battle-tested Nginx configuration for Magento (source: www.hypernode.com)
View magento-nginx.conf
# This is an annotated subset of the Nginx configuration from our Magento production platform @ www.hypernode.com
# See https://www.byte.nl/blog/magento-cacheleak-issue
# !!!! If you are a Hypernode customer, do not use this config as it will result in duplicate statements. !!!!!
user app;
worker_processes 4;
pid /var/run/nginx.pid;
events {
@vpietri
vpietri / datataflow.php
Last active Jun 19, 2020
Magento shell script to run dataflow from the command line
View datataflow.php
<?php
require_once 'abstract.php';
/**
* Magento Dataflow Shell Script
*
* This file should be save in the shell directory of Magento
* Basic usage samples:
* php dataflow.php
* php dataflow.php list
@mpchadwick
mpchadwick / Mpchadwick_Missing_Acl_Checker.php
Created Jul 11, 2015
Mpchadwick_Missing_Acl_Checker.php
View Mpchadwick_Missing_Acl_Checker.php
<?php
require_once 'abstract.php';
/**
* Generate a CSV of modules with admin routes that haven't implemented _isAllowed()
*/
class Mpchadwick_Missing_Acl_Checker extends Mage_Shell_Abstract
{
const MODULES_PATH = 'modules';
View SupportDesk_FixAcl.php
<?php
/**
* SupportDesk_FixAcl.php v1.1
* SupportDesk (www.supportdesk.nu)
* 10/7/2015
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* It is available through the world-wide-web at this URL:
@steverobbins
steverobbins / magento-ioncube-module-info.php
Last active May 12, 2021
Display what information we can about Magento1 objects that are ioncubed (or any class really)
View magento-ioncube-module-info.php
<?php ini_set('display_errors', 1) ?>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<?php
// we need the autoloader
include 'app/Mage.php';
$classes = array(
View package2modman.php
<?php
/**
* Generate modman file from Magento Connect 2.0 package.xml
*
* Usage:
*
* php package2modman.php path/to/package.xml > path/to/modman
*
*/
require_once(__DIR__ . "/../www/app/Mage.php");