Skip to content

Instantly share code, notes, and snippets.

View id_fabrizio_2016.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDylDQT7AW84cExfb2ILuzDu9Qv+Vb/W4/0CsUREnP5pEbsLbzt+4ccmPkitC1CXkhdb0Ok2GI6Vq3Y9M4pK3uYMdM4jPk+2l56nVwWkW83ysEhJmTgRaVSwoWFdRRTQeaFr5BVfOSboQb64Hs0gCm7twmDg+XUxrfci6xQFMYEglfTI86WjHosfHzEF2NLyBp5bHL6KqZ6by/Hfy5uIf2leDCWp3HwfgVzMZSgXn5VVPGU21do3fWemPKJLn4cmoBtbX6Mz1Fpx/nZsebuhb4biYH4EurrUj71LfXoy4w4VOPYUMWv0+ELss0Vc3Mz7ID5NcIU7LCQdbYd234d6Z5HbyR8A0FAKEwkEOmN0vEE8/ahCkDQuUzH/RnDJuHdnLvCN67Y/U2TipPDke/XVBW0J9Z5wBbU33QIM95A+toO/271EY7Dy2dkLp5rkmhPvrUs9Rph2IF+LE24N8Gc0Wn/BIBw94oCeaWjcdAJ5nuOQmL+MUU/H1FCU3uDeQ1kuJ9VyxKgHlpa2LppIOQ6mlMgVdGMUzn6uf4Hv3FyVvURx7cn+kbbuxTuAnrQWZhTcN+jjDNxCNLVNmh6SWz/J5eZm3kGTZdcehF0FNhBQP+SogmjSKurtRtPHyT3lvToXktqlnbsAAOh+dFp5Xt48QfIZ7knltipIKqBvnnxQ7BvDQ== Fabrizio 2016
@fbrnc
fbrnc / AjaxLoader.ino
Last active May 3, 2018
Hardware AJAX Loader using an Attiny85, 3 potentiometers and a 24 RGB LED ring
View AjaxLoader.ino
#include <FastLED.h>
#define NUM_LEDS 24
#define NUM_DOTS 3
#define DATA_PIN 0
#define MAX_SPEED 60
using namespace std;
CRGB leds[NUM_LEDS];
@fbrnc
fbrnc / gist:1705041
Created Jan 30, 2012
Magento switch to one column
View gist:1705041
<!-- do this: -->
<catalog_category_default>
<update handle="page_one_column" />
</catalog_category_default>
<!-- Also possible, but won't apply other settings that might be attached to the 1column layout (so don't do that...): -->
@fbrnc
fbrnc / gist:a758315e2d9af024ab0f
Last active Mar 11, 2018
What's wrong with Catalogrule's cron job?
View gist:a758315e2d9af024ab0f

catalogrule/observer::dailyCatalogUpdate called by the catalogrule_apply_all cron job will delete block caches every night:

https://github.com/OpenMage/magento-mirror/blob/magento-1.9/app/code/core/Mage/CatalogRule/Model/Rule.php#L319

What's wrong with this?

  1. It shouldn't do this if there are no catalog rules in the first place.
  2. Even if there are catalog rules it should check if the current execution time is close to any job's start or stop date and only flush caches then.
  3. The configuration (https://github.com/OpenMage/magento-mirror/blob/magento-1.9/app/code/core/Mage/CatalogRule/etc/config.xml#L102-104) basically only allows adding caches, but not removing any caches.
  4. Cleaning caches - if actually required - should happen after reindexing. It's not safe to assume that noone will hit any affected page after it was cleaned and before the indexers are done.
@fbrnc
fbrnc / gist:8ed33626f2fdeb4507df
Created Aug 13, 2014
Install Chef and Berkshelf on Ubuntu
View gist:8ed33626f2fdeb4507df
#!/bin/bash
apt-get -y update
apt-get -y install build-essential ruby-dev git curl build-essential libxml2-dev libxslt-dev libssl-dev autoconf
if [ ! -e /opt/chef/bin/chef-solo ] ; then
curl -L https://www.opscode.com/chef/install.sh | bash
fi
if [ ! -e /opt/chef/embedded/bin/berks ] ; then
/opt/chef/embedded/bin/gem install berkshelf --no-ri --no-rdoc
@fbrnc
fbrnc / gist:4550079
Last active Sep 25, 2017 — forked from michalochman/gist:3175175
Make Behat/Mink create a screenshot when a test fails
View gist:4550079
<?php
class FeatureContext extends MinkContext {
/**
* Take screenshot when step fails.
* Works only with Selenium2Driver.
*
* @AfterStep
*/
View grafana_backup.sh
BASEURL=http://username:password@127.0.0.1:3000
for dash in $(curl -s -k "${BASEURL}/api/search" | jq -r '.[].title'); do
curl -k "${BASEURL}/api/dashboards/db/${dash}" > "${dash}.json"
done
@fbrnc
fbrnc / gist:1262502
Created Oct 4, 2011
Magento priority configuration for TwoLevels cache backend
View gist:1262502
Index: app/code/core/Mage/Core/Model/Cache.php
===================================================================
--- app/code/core/Mage/Core/Model/Cache.php (revision 124392)
+++ app/code/core/Mage/Core/Model/Cache.php (working copy)
@@ -44,7 +44,7 @@
/**
* Cache frontend API
*
- * @var Zend_Cache_Core
+ * @var Varien_Cache_Core
@fbrnc
fbrnc / Varien_Cache_Backend_Database.patch
Created May 13, 2011
Patch for Magento's database backend
View Varien_Cache_Backend_Database.patch
Index: lib/Varien/Cache/Backend/Database.php
===================================================================
--- lib/Varien/Cache/Backend/Database.php (revision 63515)
+++ lib/Varien/Cache/Backend/Database.php (working copy)
@@ -224,6 +224,7 @@
if ($this->_options['store_data']) {
$adapter = $this->_getAdapter();
$result = $adapter->delete($this->_getDataTable(), array('id=?'=>$id));
+ $tagResult = $adapter->delete($this->_getTagsTable(), array('cache_id=?' => $id));
return $result;
@fbrnc
fbrnc / is_leader.sh
Last active Mar 13, 2017
"Good enough" leader election script for AWS AutoScalingGroups
View is_leader.sh
#!/usr/bin/env bash
function echoerr { echo "$@" 1>&2; }
function error_exit { echoerr "$1"; exit 1; }
if [ -z "${REGION}" ] ; then error_exit "No REGION set"; fi
command -v jq >/dev/null 2>&1 || error_exit "'jq' not found"
command -v aws >/dev/null 2>&1 || error_exit "'aws' not found"
command -v tee >/dev/null 2>&1 || error_exit "'tee' not found"
command -v ec2metadata >/dev/null 2>&1 || error_exit "'ec2metadata' not found"