Skip to content

Instantly share code, notes, and snippets.

View cosimo's full-sized avatar
🇳🇴

Cosimo Streppone cosimo

🇳🇴
View GitHub Profile
@cosimo
cosimo / wget-exit-codes.txt
Last active March 25, 2025 18:52
wget exit codes
This is the list of exit codes for wget:
0 No problems occurred
1 Generic error code
2 Parse error — for instance, when parsing command-line options, the .wgetrc or .netrc…
3 File I/O error
4 Network failure
5 SSL verification failure
6 Username/password authentication failure
7 Protocol errors

When varnish logs a Hit entry (SLT_Hit), it means the vcl_recv() function has given a go for serving the request from cache and the object is available.

This however doesn't guarantee that our request was served from the cache. The default vcl_hit() code (man vcl) checks that the object has to be cacheable too, at least on varnish 2.1.

if (!obj.cacheable) {

@cosimo
cosimo / squeeze-backports-kernel.sh
Created January 25, 2013 12:30
Upgrade Debian Squeeze with backports kernel (3.2.0)
#!/bin/sh
echo 'deb http://backports.debian.org/debian-backports squeeze-backports main contrib non-free' > /etc/apt/sources.list.d/squeeze-backports.list
apt-get update
apt-get -t squeeze-backports install linux-base initramfs-tools linux-image-3.2.0-0.bpo.4-amd64
@cosimo
cosimo / anyevent-udp-server.pl
Created January 13, 2013 11:12
Simple AnyEvent UDP server
#!/usr/bin/perl
=head1 NAME
anyevent-udp-server.pl - Simple AnyEvent::Handle::UDP UDP server
=head1 DESCRIPTION
Starts a UDP server that listens on a given port for
input (incoming udp packets).
@cosimo
cosimo / parse-options.sh
Created September 21, 2012 09:31
Example of how to parse options with bash/getopt
#!/bin/bash
#
# Example of how to parse short/long options with 'getopt'
#
OPTS=`getopt -o vhns: --long verbose,dry-run,help,stack-size: -n 'parse-options' -- "$@"`
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
echo "$OPTS"
sub vcl_fetch {
# ...
if (beresp.http.Cache-Control ~ 'no-cache') {
set beresp.ttl = 0s;
return (deliver);
}
# ...
@cosimo
cosimo / custom-head.html
Created August 25, 2012 08:57
OSQA responsive layout
<meta name="viewport" content="width=device-width, initial-scale=1">
@cosimo
cosimo / find-unused-css-selectors.pl
Created July 26, 2012 14:09
Find unused CSS selectors across a list of URLs
#!/usr/bin/env perl
#
# Find unused CSS selectors by crawling a list of URLs
# (--url, even more than one) and matching all elements in
# a page to find out which selectors are never used across
# all given URLs
#
# Usage:
# ./find-unused-css-selectors.pl --css file.css --url http://some.url [--url http://some.other.url ...]
#
@cosimo
cosimo / default.vcl
Created May 30, 2012 13:34
Attempt to transpose libvmod-shield to varnish 2.1
include "/etc/varnish/reset-connection.vcl";
backend default {
.host = "127.0.0.1";
.port = "8080";
}
sub vcl_recv {
if (req.http.CloseMe) {
C{
@cosimo
cosimo / mytap_exception.my
Created April 2, 2012 19:04
mytap.dies_ok() ?
DELIMITER //
DROP PROCEDURE IF EXISTS populate_table //
CREATE PROCEDURE populate_table ()
BEGIN
DECLARE CONTINUE HANDLER FOR SQLSTATE '23000' BEGIN
SELECT tap.ok(
0,