Skip to content

Instantly share code, notes, and snippets.

@fbrnc
fbrnc / xe.js
Created Aug 26, 2015
Send a daily email with a screenshot of the current USD/EUR conversion rate attached to it.
View xe.js
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 Jul 2, 2016
Fish config (~/.config/fish/config.fish)
View 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 Aug 4, 2015
Magento Core Hacks :)
View empty_filename.diff
--- 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 {
View gist:ce477c92d027a8263271
<?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 Feb 17, 2020
Magento XML Connect Demo
View gist:bdade1df328c3f766a3c
<?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 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:39b387273a890a1338b9
Last active Aug 29, 2015
Login to your devbox using ngrok
View gist:39b387273a890a1338b9

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 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:f4e9fd908c8e01754b71
Created Jul 25, 2014
Make Magento System Configuration tabs collapsable
View gist:f4e9fd908c8e01754b71
// 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 Jul 4, 2014
Jenkins Build Pipeline Custom CSS
View gist:66f9753144a5ea8db0c1
#build-pipeline-plugin-content {
background-color: none;
border-radius: 0;
}
#build-pipeline-plugin-content h1 {
display: none;
}
tbody.pipelineGroup {