Skip to content

Instantly share code, notes, and snippets.

View fbrnc's full-sized avatar

Fabrizio Branca fbrnc

  • AOE
  • Wiesbaden, Germany
  • X @fbrnc
View GitHub Profile
@fbrnc
fbrnc / xe.js
Created August 26, 2015 04:21
Send a daily email with a screenshot of the current USD/EUR conversion rate attached to it.
var page = require('webpage').create();
page.viewportSize = { "width": 1024, "height": 1500 };
page.clipRect = { "top": 530, "left": 20, "width": 650, "height": 541 };
page.open('http://www.xe.com/currencycharts/?from=USD&to=EUR&view=1M', function() {
setTimeout(function() {
page.evaluate(function() {
document.body.bgColor = 'white';
});
page.render('xe.png');
phantom.exit();
@fbrnc
fbrnc / config.fish
Last active July 2, 2016 23:03
Fish config (~/.config/fish/config.fish)
# Path to your oh-my-fish.
set fish_path $HOME/.oh-my-fish
# Path to your custom folder (default path is ~/.oh-my-fish/custom)
#set fish_custom $HOME/dotfiles/oh-my-fish
# Load oh-my-fish configuration.
. $fish_path/oh-my-fish.fish
function fish_user_key_bindings
@fbrnc
fbrnc / empty_filename.diff
Created August 4, 2015 03:00
Magento Core Hacks :)
--- app/code/local/Mage/Core/Block/Template.php 2015-08-04 02:46:44.204327968 +0000
+++ app/code/core/Mage/Core/Block/Template.php 2015-08-04 02:46:46.504296112 +0000
@@ -237,7 +237,7 @@
try {
$includeFilePath = realpath($this->_viewDir . DS . $fileName);
- if (!empty($includeFilePath) && (strpos($includeFilePath, realpath($this->_viewDir)) === 0 || $this->_getAllowSymlinks())) {
+ if (strpos($includeFilePath, realpath($this->_viewDir)) === 0 || $this->_getAllowSymlinks()) {
include $includeFilePath;
} else {
<?php
class Mage_Core_Block_Template:
public function fetchView($fileName):
if (strpos($includeFilePath, realpath($this->_viewDir)) === 0 || $this->_getAllowSymlinks()) {
if (empty($includeFilePath)) {
Mage::log("Resulting in empty includeFilePath: $fileName");
} else {
@fbrnc
fbrnc / gist:bdade1df328c3f766a3c
Last active July 7, 2021 11:59
Magento XML Connect Demo
<?php
// Initialize
$app = new SimpleHttpClient('http://www.demo.local/xmlconnect/');
$app->addCookie('app_code', 'INSERT APP CODE HERE');
$app->addCookie('screen_size', '600x400');
// get products in category 3
@fbrnc
fbrnc / gist:a758315e2d9af024ab0f
Last active March 11, 2018 07:49
What's wrong with Catalogrule's cron job?

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:39b387273a890a1338b9
Last active August 29, 2015 14:13
Login to your devbox using ngrok

How to remotely login to a devbox using ngrok

  • Go to https://ngrok.com/ and create a free account. Write down the "auth token"

  • Login to your unibox and install ngrok:

sudo apt-get install ngrok-client
@fbrnc
fbrnc / gist:8ed33626f2fdeb4507df
Created August 13, 2014 03:27
Install Chef and Berkshelf on Ubuntu
#!/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:f4e9fd908c8e01754b71
Created July 25, 2014 04:20
Make Magento System Configuration tabs collapsable
// Quick'n'dirty
// TODO:
// - store status in a cookie
// - restore status from cookie
// - prevent tab that contains active tabs from being collapsed
// - change icon when collapsed
// - change mouse pointer
$$('#system_config_tabs dt.label').each(function(s) {
s.observe('click', function(label) {
s.siblings().each(function(a) { a.toggle(); })
@fbrnc
fbrnc / gist:66f9753144a5ea8db0c1
Created July 4, 2014 03:46
Jenkins Build Pipeline Custom CSS
#build-pipeline-plugin-content {
background-color: none;
border-radius: 0;
}
#build-pipeline-plugin-content h1 {
display: none;
}
tbody.pipelineGroup {