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 / shared_memory.sh
Last active Aug 29, 2015
Move given directories to shared memory and create symlinks
View shared_memory.sh
#!/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 Jun 12, 2014
Instell chef-solo and berkshelf (on Ubuntu)
View gist:a6e2ef9630969a094f58
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
View gist:147bc6eaf187a15f1f75
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 Jul 1, 2014
Install PHP 5.4 on AWS Opsworks Ubuntu 12.04 (note that Ubuntu 14.04 will install PHP 5.5 by default)
View gist:165c961546447bf44ab3
# 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 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: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
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 / 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 {
@fbrnc
fbrnc / Varien_Cache_Core.patch
Created May 13, 2011
Patch for Magento's two-level cache priority bug
View Varien_Cache_Core.patch
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)