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 / shared_memory.sh
Last active August 29, 2015 14:00
Move given directories to shared memory and create symlinks
#!/bin/bash
for i in "$@" ; do
if [ -h $i ] ; then
echo "$i is a symlink";
SYMLINKTARGET=$(readlink -f "$i")
unlink "$i" || { echo "Error unlinking $i"; exit 1; }
if [ -d $SYMLINKTARGET ] ; then
echo "Moving $SYMLINKTARGET to $i"
@fbrnc
fbrnc / gist:a6e2ef9630969a094f58
Created June 12, 2014 02:27
Instell chef-solo and berkshelf (on Ubuntu)
sudo su
apt-get update && apt-get install -y curl build-essential git libxml2-dev libxslt-dev libssl-dev
curl -L https://www.opscode.com/chef/install.sh | bash
/opt/chef/embedded/bin/gem install berkshelf --no-ri --no-rdoc
ln -s /opt/chef/embedded/bin/berks /usr/local/bin/berks
@fbrnc
fbrnc / gist:147bc6eaf187a15f1f75
Created June 15, 2014 15:32
Setup Samba on devbox
sudo apt-get -y install samba
# Set a password for your user in Samba (use "vagrant" as password)
sudo smbpasswd -a vagrant
# Add this to /etc/samba/smb.conf
[www]
path = /var/www
available = yes
valid users = vagrant
@fbrnc
fbrnc / gist:165c961546447bf44ab3
Created July 1, 2014 17:11
Install PHP 5.4 on AWS Opsworks Ubuntu 12.04 (note that Ubuntu 14.04 will install PHP 5.5 by default)
# Add this to the "setup" activity:
apt_repository "custom-php5-oldstable" do
uri "http://ppa.launchpad.net/ondrej/php5-oldstable/ubuntu"
distribution node['lsb']['codename']
components ["main"]
keyserver "keyserver.ubuntu.com"
key "E5267A6C"
action :nothing
subscribes :add, "template[/etc/sudoers]", :immediately
@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: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
<?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 / 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 {
@fbrnc
fbrnc / Varien_Cache_Core.patch
Created May 13, 2011 21:04
Patch for Magento's two-level cache priority bug
Index: lib/Varien/Cache/Core.php
===================================================================
--- lib/Varien/Cache/Core.php (revision 63515)
+++ lib/Varien/Cache/Core.php (working copy)
@@ -70,7 +70,7 @@
* @throws Zend_Cache_Exception
* @return boolean True if no problem
*/
- public function save($data, $id = null, $tags = array(), $specificLifetime = false, $priority = 8)
+ public function save($data, $id = null, $tags = array(), $specificLifetime = false, $priority = 10)