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 / 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

<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define :serf do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
@hernandesbsousa
hernandesbsousa / etc-nginx-nginx.conf
Created May 9, 2014 17:59 — forked from aaronfeng/etc-nginx-nginx.conf
Nginx logging in JSON format
# /etc/nginx/nginx.conf
log_format main '{'
'"remote_addr": "$remote_addr",'
'"remote_user": "$remote_user",'
'"time_local": "$time_local",'
'"request": "$request",'
'"status": "$status",'
'"body_bytes_sent": "$body_bytes_sent",'
'"http_referer": "$http_referer",'
@hernandesbsousa
hernandesbsousa / nginx-font-serving
Last active November 17, 2015 01:08 — forked from atiw003/nginx-font-serving
CORS setup for Nginx/Apache
For nginx,
location ~* \.(eot|ttf|woff)$ {
add_header Access-Control-Allow-Origin *;
}
Or better way inside virtual host location use,
Inside location use
if ($request_filename ~* ^.?/([^/]?)$)
@hernandesbsousa
hernandesbsousa / friday_deploy_cap2.rb
Last active August 28, 2015 20:49 — forked from exAspArk/friday_deploy_cap2.rb
Friday deploy script for Capistrano
# Capistrano 2
before "deploy", "friday:good_luck"
namespace :friday do
friday_jumper = %{
┓┏┓┏┓┃
┛┗┛┗┛┃⟍ ○⟋
┓┏┓┏┓┃ ∕ Friday
┛┗┛┗┛┃ノ)