Skip to content

Instantly share code, notes, and snippets.

View cosimo's full-sized avatar
🇳🇴

Cosimo Streppone cosimo

🇳🇴
View GitHub Profile

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 / wget-exit-codes.txt
Last active September 15, 2023 10:09
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
@cosimo
cosimo / gist:8402026
Created January 13, 2014 15:12
How we manage users, groups and ssh keys with puppet for now
class mycompany::admins::cosimo {
realize( Group['devops'] )
mycompany::admin { 'cosimo':
gid => 2002,
fullname => 'Cosimo',
group => 'devops',
}
@cosimo
cosimo / pylint.vim
Created February 12, 2014 10:51
Pylint Vim compiler plugin that works...
" Vim compiler file for Python
" Compiler: Style checking tool for Python
" Maintainer: Oleksandr Tymoshenko <gonzo@univ.kiev.ua>
" Last Change: 2014 Feb 12 (Cosimo)
" - Removed the pylint rate parsing and display
" - Fixed errorformat for current Pylint versions
" Version: 0.6-dev
" Contributors:
" Artur Wroblewski
" Menno
@cosimo
cosimo / pre-commit
Created February 26, 2014 12:59
Puppet manifests and templates syntax check git pre-commit hook
#!/bin/bash
# pre-commit hook to syntax check puppet manifests and erb templates
# at checkin.
# Stig Sandbeck Mathisen <ssm@fnord.no>
#
# Modified to run with puppet < 2.7 as well, Cosimo 13/Dec/2011
#
# Requirements:
perl6-lwp-simple $ ufo
No such method 'split' for invocant of type 'CompUnitRepo::Local::Installation'
in sub mkpath at /home/cosimo/.perl6/2014.05-118-ge88e462/bin/ufo:161
in sub get_prefix at /home/cosimo/.perl6/2014.05-118-ge88e462/bin/ufo:148
in sub MAIN at /home/cosimo/.perl6/2014.05-118-ge88e462/bin/ufo:69
in block at /home/cosimo/.perl6/2014.05-118-ge88e462/bin/ufo:221
@cosimo
cosimo / rtail
Created September 22, 2014 14:45
#!/usr/bin/perl
=head1 NAME
rtail - tail multiple files remotely
=head1 SYNOPSIS
./rtail --host h1 --host h2 --command 'tail -f /var/log/syslog'
./rtail --user someuser --host h1 --host h2 --command 'uname -a'
@cosimo
cosimo / graphite-null-value-aggregates-problem
Created November 21, 2014 10:03
Problem with graphite aggregates and NULL values coming from some hosts
We're using graphite 0.9.12.
We have per-datacenter aggregates and total-across-datacenters
aggregates, constructed as follows (flush interval is 10s):
# Total
<project>.<env>.aggregates.total.recommender.api.suggestions.rate (10) = sum <project>.<env>.*.*.counters.recommender.api.suggestions.rate
# Per-datacenter
<project>.<env>.aggregates.dc.<datacenter>.recommender.api.suggestions.rate (10) = sum <project>.<env>.<datacenter>.*.counters.recommender.api.suggestions.rate
@cosimo
cosimo / Shortener.py
Created March 30, 2015 13:35
Simple class used to generate "shortened" URLs
import math
class Shortener:
"""
Simple class to shorten URLs, or rather, numerical IDs.
Each URL must be saved to a database, with the data about source,
category, country, publisher, etc... The database will give back
a numerical ID. We're using that ID to convert it to a base 62
number and using a symbol table, converting it to a sequence
@cosimo
cosimo / check-powerdns-running.sh
Created May 12, 2015 13:17
Check if powerdns is alive and well
#!/bin/bash
#
# Powerdns sometimes will stall and keep two pipe backend processes
# for no apparent reason, and fill the logs with "Unable to bind to UDP socket"
# events. When that happens, then DNS service becomes unresponsive and
# doesn't answer queries.
#
# This script tries to detect such condition and will exit with a
# high status code (> 90) or zero if everything looks good.
#