Skip to content

Instantly share code, notes, and snippets.

View aleron75's full-sized avatar

Alessandro Ronchi aleron75

View GitHub Profile
@aleron75
aleron75 / setup_db_status.sh
Created August 12, 2016 12:33
Bash script to get different exit codes upon the bin/magento setup:db:status command
#!/bin/bash
# use --no-ansi to avoid color characters
message=$(bin/magento setup:db:status --no-ansi)
if [[ ${message:0:3} == "All" ]];
then
exit 0 # 0 not required being default exit code; used for clarity
else
exit 1
fi
@aleron75
aleron75 / getip.sh
Created September 17, 2016 09:17
Get IP address on local network interface
#!/bin/bash
ip addr show eno1 | grep -oPi 'inet \K[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
@aleron75
aleron75 / 0_reuse_code.js
Created September 22, 2016 12:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@aleron75
aleron75 / check_xml.sh
Created January 17, 2016 09:31
Validate all config.xml files to spot XML syntax errors
find . -type f -name 'config.xml' -exec xmllint --noout {} \;
@aleron75
aleron75 / .bashrc
Created November 19, 2015 13:43
XEBUG on/off alias
alias xdebugon='export XDEBUG_CONFIG="idekey=phpstorm-xdebug" && sudo mv /etc/php5/mods-available/xdebug.ini.no /etc/php5/mods-available/xdebug.ini && sudo service apache2 restart'
alias xdebugoff='sudo mv /etc/php5/mods-available/xdebug.ini /etc/php5/mods-available/xdebug.ini.no && sudo service apache2 restart'
@aleron75
aleron75 / heydidyoujusteditthecore.sh
Last active August 29, 2015 14:26
Checks whether Magento core files were changed against a vanilla installation
#!/bin/bash
# Requirements: patchutils - Utilities to work with patches
# Credits: http://inchoo.net/magento/quickly-check-if-magento-core-files-are-modified/
if [ $# -ne 2 ]; then
echo "Usage:"
echo "heydidyoujusteditthecore.sh <default_sacred_core_folder> <clients_core_folder>"
exit 1
fi
default_sacred_core_folder="$1"
@aleron75
aleron75 / gitlog.sh
Created June 30, 2015 07:33
Decorated git log
#!/bin/bash
git log --graph --decorate --pretty=oneline --abbrev-commit
@aleron75
aleron75 / privateaccess.php
Created June 19, 2015 07:56
POC that PHP doesn't allow calling private methods from inherited context
<?php
class MyParent
{
public function includeFile()
{
include "privateaccess_included.php";
}
}
class MyChild extends MyParent
@aleron75
aleron75 / Data.php
Created June 16, 2015 09:09
Magento Compare Version
<?php
class Myvendor_Mymodule_Helper_Data extends Mage_Core_Helper_Data
{
/**
* Check whether current Magento version supports Transactions
*/
public function isTransactionSupported()
{
return version_compare(Mage::getVersion(), '1.4.0.1', '>');
}
@aleron75
aleron75 / log.php
Last active August 29, 2015 14:18
Magento log wrapper function
public function log()
{
$args = func_get_args();
$formattedMsg = call_user_func_array('sprintf', $args);
Mage::log($formattedMsg, null, 'vendor_module.log', Mage::getStoreConfig('path/to/config'));
}