Skip to content

Instantly share code, notes, and snippets.

/**
* Validate password
*
* @param Varien_Object $object
* @return bool
*/
public function validate($object)
{
$password = $object->getPassword();
@andkirby
andkirby / debug_wrapper.php
Last active April 1, 2016 13:48
This class can wrap each method in a class with custom code.(it wasn't tested with namespaces)
<?php
/**
* Usage:
* <?php
* // target class which should be wrapped
* class Class_For_Testing extends stdClass
* {
* public static function complexParams(stdClass $a, array &$foo = null, $bar = 'baz')
* {
* echo 'This is a test1' . PHP_EOL;
@andkirby
andkirby / ps-git.sh
Last active April 22, 2016 06:59
Example of PS1 with condition.
#!/usr/bin/env bash
alias __ch_task='if [[ "" != $(git rev-parse --git-dir 2> /dev/null) ]]; then echo -n $(ch config task); fi;'
export PS1='$(__ch_task)'
@andkirby
andkirby / slack-log-monitor.sh
Last active June 30, 2016 12:19
Magento Exceptions Log Monitor for Slack.
#!/usr/bin/env bash
# This script can send Magento 1.x exception messages to Slack
#
# This file can be added to the root of a project
# Please be sure that you have a file var/log/exception.log in your project
#
# Run this file in background via command with "&" in the end
# $ slack-log-monitor.sh [OPTIONS] &
# See more options by command: $ slack-log-monitor.sh --help
$a = new ArrayIterator;
$a->append(++$cnt);
$a->append(++$cnt);
foreach ($a as $i => $item) {
$cnt < 5 && $a->append(++$cnt);
var_dump($item);
}
//int(1)
//int(2)
@andkirby
andkirby / .phpstorm.meta.php
Created July 29, 2016 15:14
Symfony console .phpstorm.meta.php file for helpers. Actual for v3.1.2.
<?php
namespace PHPSTORM_META { // we want to avoid the pollution
/** @noinspection PhpUnusedLocalVariableInspection */
/** @noinspection PhpIllegalArrayKeyTypeInspection */
$STATIC_METHOD_TYPES = [
\Symfony\Component\Console\Command\Command::getHelper('') => [
'question' instanceof \Symfony\Component\Console\Helper\QuestionHelper,
'process' instanceof \Symfony\Component\Console\Helper\ProcessHelper,
'debug_formatter' instanceof \Symfony\Component\Console\Helper\DebugFormatterHelper,
'descriptor' instanceof \Symfony\Component\Console\Helper\DescriptorHelper,
@andkirby
andkirby / local.xml
Last active September 6, 2016 19:30
Magento local.xml example for enabling Redis for cache and Memcached for sessions.
<?xml version="1.0"?>
<config>
<global>
<session_save><![CDATA[memcached]]></session_save>
<session_save_path><![CDATA[127.0.0.1:11211?persistent=0&weight=2&timeout=10&retry_interval=10]]></session_save_path>
<cache>
<backend>Mage_Cache_Backend_Redis</backend>
@andkirby
andkirby / vbox_direct_ports.rb
Last active October 18, 2016 13:15
This file can help to set forwarded ports in VirtualBox VM. It solves the problem described in the issue https://github.com/mitchellh/vagrant/issues/7905
require 'yaml'
require 'digest/md5'
##
# Module VBoxDirectPorts
# It add ports forwarding in VirtualBox VM
# It can generate ports based upon hostname
#
# Configuration files.
# (.dist) means there is should be distributive file by default with default configuration
@andkirby
andkirby / shell_color.sh
Created October 22, 2016 11:57
colored text in bash
# t_color COLOR_NO MESSAGE [STYLE_NO]
t_color () {
local style
style=$([ -n "$3" ] && echo 0 || echo $3)
echo -e '\e['$3';'$1'm'$2'\e[0m'
}
t_warning () {
echo -e '\e[0;33m'$1'\e[0m'
}
t_ok () {
@andkirby
andkirby / sscp
Last active October 23, 2016 15:33
Download/uplod script for remote environments.
#!/usr/bin/env bash
# Download this file in Windows GitBash
# curl -Ls https://gist.github.com/andkirby/cbeaad9fbedcbce6cf20bf5ba5467e59/raw/sscp -o /usr/bin/sscp
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
readonly SCRIPT_DIR
show_help () {
echo -e "