Skip to content

Instantly share code, notes, and snippets.

View janpapenbrock's full-sized avatar

Jan Papenbrock janpapenbrock

View GitHub Profile
<?php
// Init framework
require 'app/Mage.php';
Mage::app();
// Factory methods to search for
$methods = array(
'Mage::helper',
'Mage::getModel',
'Mage::getResourceModel',
@janpapenbrock
janpapenbrock / mage_ifconfig.xml
Last active December 15, 2015 20:19
Magento XML: ifconfig example from ajaxsearch
<reference name="left">
<block type="core/template" name="left.search" as="leftSearch" before="-">
<action method="setTemplate" ifconfig="ajax_search/general/enabled"><template>ajaxsearch/leftsearch.phtml</template></action>
</block>
</reference>
@janpapenbrock
janpapenbrock / git-tools.md
Last active December 18, 2015 03:48
Useful git commands
@echo off
setlocal enabledelayedexpansion
REM
REM PngOutBatch
REM
REM Nic Jansma - nic@nicj.net
REM
REM Runs a PNG through PngOut multiple times at different block sizes. Shows the
REM file-size savings during and at the end.
@janpapenbrock
janpapenbrock / profiling-controller.php
Created December 18, 2014 13:16
Magento Controller only displaying profiling information of Magento initialization
public function indexAction()
{
$html = $this->getLayout()
->createBlock('core/profiler')
->toHtml();
$this->getResponse()->setBody($html);
}
# Send a metric to statsd from bash
#
# Useful for:
# deploy scripts (http://codeascraft.etsy.com/2010/12/08/track-every-release/)
# init scripts
# sending metrics via crontab one-liners
# sprinkling in existing bash scripts.
#
# netcat options:
# -w timeout If a connection and stdin are idle for more than timeout seconds, then the connection is silently closed.
#!/bin/sh
set -e
set -x
LOG_DIR=$HOME/graphite-volumes/var-log
DATA_DIR=$HOME/graphite-volumes/graphite-storage
VOLUMES_INIT_CONTAINER_NAME=graphite-volumes-init
@janpapenbrock
janpapenbrock / create_hash.php
Created November 27, 2015 09:23
Magento Create Admin User Password Hash
<?php
define('MAGENTO', realpath(dirname(__FILE__)));
require_once (MAGENTO . '/app/Mage.php');
Mage::app();
$password = 'super-secret';
$hash = Mage::helper('core')->getHash($password, Mage_Admin_Model_User::HASH_SALT_LENGTH);
@janpapenbrock
janpapenbrock / install.sh
Created January 7, 2016 13:38
Xhprof to flamegraph
#!/bin/bash
INSTALL_DIR="~/third-party/"
mkdir -p "$INSTALL_DIR"
cd "$INSTALL_DIR"
git clone https://github.com/brendangregg/FlameGraph
sudo ln -s "$INSTALL_DIR"/FlameGraph/flamegraph.pl /usr/local/bin/flamegraph.pl
@janpapenbrock
janpapenbrock / graphite-dashboard-tool.sh
Created January 4, 2017 12:55 — forked from toni-moreno/graphite-dashboard-tool.sh
A shell script to help export/import json formatted graph and dashboards from a Graphite mysql database.
#!/bin/bash
# (c) Toni Moreno
# tool to import / export graphs and dashboards to mysql db
# NOTE: be sure you have granted FILE privileges
# if apparmor is configured you should add to
# /etc/apparmor.d/usr.sbin.mysqld
# /tmp/* rw,
LOCAL_SETINGS="/opt/graphite/webapp/graphite/local_settings.py"