Skip to content

Instantly share code, notes, and snippets.

Peter Jaap Blaakmeer peterjaap

Block or report user

Report or block peterjaap

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
peterjaap / soldprod.php
Created Dec 3, 2012
Sold products % by category
View soldprod.php
$orders = Mage::getModel('sales/order')->getCollection();
$i = 0;
foreach ($orders as $key => $order) {
if (!$i) {
$startDate = strtotime($order->getCreatedAt());
peterjaap / quickmodman
Created Jan 16, 2013
Quickly generate modman file for Magento extensions
View quickmodman
for i in `find . -type f | grep -v \.git | grep -v "^.$" | grep -v "modman" | sed 's/\.\///'`; do echo ${i} ${i}; done > modman
peterjaap / search_autofocus.js
Last active Dec 14, 2015
Prototype javascript thingy to autofocus on search element on typing (ignoring navigational keys) and setting the search box as the first tab index
View search_autofocus.js
Event.observe(window,'load',function() {
$('search').tabIndex = 1;
$(document).observe('keyup', function(e) {
if(Event.element(e) == document.body) {
$('search').value = String.fromCharCode(e.keyCode).toLowerCase();
peterjaap / betterforgotpassword.js
Last active Dec 14, 2015
This little snippet improves the 'forgot password' workflow in a Magento shop by adding a button (after a failed login attempt) that directly posts the email address to the forgot password action ----------- Idea inspired by
View betterforgotpassword.js
Event.observe(window, "load", function(){
if(document.location.href.indexOf('customer/account/login')>0 && $$('ul.messages li.error-msg ul li span').length>0) { // check for login page and actual error message
$('pass').addClassName('validation-failed').focus(); // add red dotted lining & set focus to the password field
$('pass').insert({after: '<div class="validation-advice" id="advice-required-entry-pass" style="">Your password is incorrect.</div>'}); // add an error message below the password field
$$('div.buttons-set > a').first().remove(); // remove the Forgot Password link
$$('ul.messages li.error-msg ul li span').first().innerHTML+=' <a href="javascript:newPasswordSubmit()">Click here to reset your password</a>'; // add an actionable link to the error message
$('send2').insert({after: '<button type="button" class="button" title="Reset my password" name="send" id="forgotpass" onclick="newPasswordSubmit()"><span><span>Reset my password</span></span></button>'}
peterjaap / navicat_tunnel.php
Created Mar 13, 2013
Navicat tunnel file (the nearly unfindable ntunnel_mysql.php)
View navicat_tunnel.php
<?php //version my104
header("Content-Type: application/octet-stream");
function phpversion_int()
list($maVer, $miVer, $edVer) = split("[/.-]", phpversion());
peterjaap / FixConsole.xml
Last active Jul 16, 2017 — forked from astorm/gist:992233
Fix Magento console in Chrome
View FixConsole.xml
<!-- Add to the package layout (via local.xml or however you prefer) -->
<!-- Also, best to remove before deployment, as some users report -->
<!-- it makes IE 7 crash -->
<reference name="content">
<block type="core/text" name="fix.console" as="fix.console">
<action method="setText">
<text><![CDATA[<script type="text/javascript">
iframe = document.createElement('iframe'); = 'none';
peterjaap / createAdminUser.php
Created Apr 24, 2013
PHP script to create admin user for Magento
View createAdminUser.php
error_reporting(E_ALL | E_STRICT);
require_once 'app/Mage.php';
ini_set('display_errors', 1);
$username = 'peterjaap';//desired username
peterjaap / Notifier.php
Last active Dec 17, 2015
Notifier class for Raspberry notifications. Replace values on line 13, 34, 35, 46, 47, 108, 117 and 118 to your context. Current values line 46 and 47 are defaults for Ziggo modems (Dutch ISP). You'll also need: - A Raspberry Pi ;-) - Simple HTML DOM class; - Pushover account ( - Push…
View Notifier.php
class Notifier {
public function __construct() {
require_once 'simple_html_dom.php';
peterjaap / cleanImages.php
Last active Jan 11, 2019
Script to clean up the images tables in a Magento installation. Removes references to non-existing images, removes duplicate images, sets correct default image and deletes orphaned images from the filesystem.
View cleanImages.php
* This script deletes duplicate images and imagerows from the database of which the images are not present in the filesystem.
* It also removes images that are exact copies of another image for the same product.
* And lastly, it looks for images that are on the filesystem but not in the database (orphaned images).
* This script can most likely be optimized but since it'll probably only be run a few times, I can't be bothered.
* Place scripts in a folder named 'scripts' (or similar) in the Magento root.
View create_website_scope.php
// Base-name
$name = 'foobar';
// Init Magento
require_once 'app/Mage.php';
// Create the root catalog
You can’t perform that action at this time.