Skip to content

Instantly share code, notes, and snippets.

View hernandesbsousa's full-sized avatar

Hernandes Benevides de Sousa hernandesbsousa

View GitHub Profile
mkdir demo
cd demo
wget http://www.magentocommerce.com/downloads/assets/1.7.0.2/magento-1.7.0.2.tar.gz
wget http://www.magentocommerce.com/downloads/assets/1.6.1.0/magento-sample-data-1.6.1.0.tar.gz
tar -zxvf magento-1.7.0.2.tar.gz
tar -zxvf magento-sample-data-1.6.1.0.tar.gz
mv magento-sample-data-1.6.1.0/media/* magento/media/
mv magento-sample-data-1.6.1.0/magento_sample_data_for_1.6.1.0.sql magento/data.sql
mv magento/* magento/.htaccess .
chmod o+w var var/.htaccess app/etc
@hernandesbsousa
hernandesbsousa / gist:5902493
Last active December 19, 2015 05:09
Magento: Fixing getSkinUrl not picking up HTTPS properly
<?php /* Corrige problema onde getSkinUrl nao retorna endereco seguro quando necessario */
if(Mage::app()->getStore()->isCurrentlySecure())
$secureFlag = true;
else
$secureFlag = false;
?>
<span><img src="<?php echo $this->getSkinUrl('path/to/image.png', array('_secure'=>$secureFlag)) ?>" alt=""></span>
//if inside CMS static block:
@hernandesbsousa
hernandesbsousa / Category.sql
Last active December 20, 2015 07:09 — forked from ticean/Category.sql
Various Magento queries
SET @entityid = '3';
SELECT ea.attribute_id, ea.attribute_code, eav.value AS 'value', 'varchar' AS 'type'
FROM catalog_category_entity e
JOIN catalog_category_entity_varchar eav
ON e.entity_id = eav.entity_id
JOIN eav_attribute ea
ON eav.attribute_id = ea.attribute_id
WHERE e.entity_id = @entityid
UNION
#!/bin/bash
#
# Bash shell script for generating self-signed certs. Run this in a folder, as it
# generates a few files. Based on the following GIST Extract by Brad Landers:
# https://gist.github.com/bradland/1690807
#
# Additional alterations by: Hernandes B. de Sousa
# Date: 2013-10-04
#
#!/usr/bin/env bash
apt-get -y update
apt-get -y upgrade
apt-get -y install git build-essential autoconf zlib1g-dev libssl-dev \
libreadline-dev libyaml-dev libcurl4-openssl-dev curl python-software-properties \
ruby1.9.1 ruby1.9.1-dev rubygems1.9.1 irb1.9.1 ri1.9.1 rdoc1.9.1
gem install chef ruby-shadow --no-ri --no-rdoc

How to purge ('ban') an entire domain in Varnish Cache 3

I thought I'd share this because it's taken me a couple of hours to work out and the documentation is not entirely clear.

Jump to answer

ban wtf?*

First of all, the purge method used to be called purge in Varnish 2.x but they renamed it to ban in 3.0. Confusingly there is also a new command called purge too! The new purge command is much less sophisticated than ban, as (AFAIK) it only purges exactly matched items, so basically one at a time.

If you do wish to use the new purge you need to have some specific VCL in place. See here

@hernandesbsousa
hernandesbsousa / helloworld
Last active December 26, 2015 22:18
HTML Hello World
<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML>
<HEAD>
<TITLE>
A Small Hello
</TITLE>
</HEAD>
<BODY>
<H1>Hi</H1>
<P>This is very minimal "hello world" HTML document.</P>
@hernandesbsousa
hernandesbsousa / mail.php
Last active December 27, 2015 19:39
sample php mail
<?php
$to = '[email protected]';
$subject = 'Test email using PHP';
$message = 'This is a test email message';
$headers = 'From: [email protected]' . "\r\n" . 'Reply-To: ' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers, '[email protected]');
?>
@hernandesbsousa
hernandesbsousa / removeport.php
Last active January 2, 2016 11:49
Removing port from URL in PHP
<?php
$url = 'http://www.example.com:8080/index.html';
$newurl = remove_port(parse_url($url));
echo $newurl;
function remove_port($parsed_url) {
$scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
$host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
$port = '';
@hernandesbsousa
hernandesbsousa / rvm.sh
Created January 17, 2014 14:08
Installing rvm@ubuntu
curl -L https://get.rvm.io | bash -s stable
rvm requirements --autolibs=enable
rvm install 2.0.0
rvm use 2.0.0
rvm --default 2.0.0