Skip to content

Instantly share code, notes, and snippets.

# headers
# URL,Ok Volume (MB),Error Volume (MB),Ok Hits,0xx,200,206,2xx,302,304,3xx,404,4xx,Offloaded Hits,Origin Hits,Origin OK Volume (MB) ,Origin Error Volume (MB)
def parse_file(file):
lines = [l.split(',') for l in open(file) if not l.startswith('#')]
return lines
def is_cached(line):
@ernestom
ernestom / waf-summary.py
Created September 26, 2012 23:09
Akamai security report from CLF+WAF logs
#!/usr/bin/python
"""
$ rsync -avz -e ssh USER@'HOST:/var/vsftpd/trife/*201209{14,15,16,17,18}*gz' logs/
$ zcat portal*201209{14,15,16,17,18}*gz | waf-summary.py '2012/09/14 00:00' '2012/09/18 00:00' > portal-14-17_final.csv
"""
import re
import sys
from datetime import datetime, date, timedelta
from dateutil import tz
@ernestom
ernestom / shortags_fixer.php
Created August 21, 2012 18:53 — forked from panquetofobia/shortags_fixer.php
PHP short open tags fixer
<?php
/**
* Short Open Tags fixer.
*
* Usage:
* $ php -d short_open_tag=On -f shortags_fixer.php path/to/file.php
* $ for i in $(find ./ -iname "*.phtml"); do php -d short_open_tag=On -f shortags_fixer.php $i > ~/fixed.txt && cat ~/fixed.txt > $i; done
*/
function fix($file)
# Expand tabs in php files.
$ for i in $(find ./* -iname "*.php"); do awk '{sub("\t"," ",$0); print $0}' $i > ~/e.tmp && cat ~/e.tmp > $i; done
@ernestom
ernestom / connectvpn.applescript
Created August 21, 2012 17:45
Connect VPN applescript
tell application "System Events"
tell current location of network preferences
set VPNService to service "SVPN"
if exists VPNService then
connect VPNService
end if
end tell
end tell
@ernestom
ernestom / akamai-apology-retry.htm
Created June 27, 2012 23:17
HTML/JS Apology page - retry self load
<!doctype html>
<html>
<head><meta charset="utf-8"></head>
<body>
<div id="loading">
<h2>Cargando información...</h2>
<h3>Esto puede tomar unos minutos</h3>
</div>
<div id="service-unavailable">
<h2>Por favor intente más tarde, disculpe las molestias</h2>
@ernestom
ernestom / hack.sh
Created March 31, 2012 20:46 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@ernestom
ernestom / juego-caras.html
Created February 15, 2012 04:30
Identificando caras Entucine.com
<!DOCTYPE html>
<html><head><title>Caritas</title></head>
<body>
<style>
body{ padding-left:50px;}
#stage {
border:1px solid #ccc;
cursor:pointer;
background:#eee;
@ernestom
ernestom / word-frequency-counter.js
Created February 13, 2012 18:38
Bookmarklet to count word frequency
(function () {
function getBodyText(win) {
var doc = win.document,
body = doc.body,
selection, range, bodyText;
if (body.createTextRange) {
return body.createTextRange().text;
} else if (win.getSelection) {
selection = win.getSelection();
range = doc.createRange();
@ernestom
ernestom / export-tickets.go
Created December 22, 2011 22:44
Exports Assembla Tickets to GitHub Issues.
// Exports Assembla tickets in XML format to GitHub issues.
//
// Usage: $ ./export-tickets path/to/tickets.xml repository_name
//
package main
import (
"os"
"fmt"