Skip to content

Instantly share code, notes, and snippets.

@bortzmeyer
bortzmeyer / gist:996874
Created May 28, 2011 13:48
Python code to produce only "safe" filenames from an Unicode string which may contain / ; etc
import unicodedata
def escape(ustr):
result = ""
for letter in ustr:
if unicodedata.category(letter) in ['Ll', 'Lm', 'Lo', 'Lt', 'Lu', 'Nd', 'Nl', 'No']:
result += str(letter)
elif letter == '&':
result += '-and-'
elif letter == '|':
def escape(ustr):
""" Escape an Unicode string to keep only characters which are safe for a filename. """
result = []
for letter in ustr:
# Keep only letters and numbers
if unicodedata.category(letter) in ['Ll', 'Lm', 'Lo', 'Lt', 'Lu', 'Nd', 'Nl', 'No']:
result.append(str(letter))
elif letter == '&':
result.append('-and-')
elif letter == '|':
@bortzmeyer
bortzmeyer / gist:1029114
Created June 16, 2011 12:13
IPv6 traceroute to Cogent from Hurricane Electric
% traceroute6 www.cogentco.com
traceroute to cogentco.com (2001:550:1::cc01) from 2001:470:1f10:3aa::2, 30 hops max, 24 byte packets
1 bortzmeyer-1.tunnel.tserv9.chi1.ipv6.he.net (2001:470:1f10:3aa::1) 10 ms 19.999 ms 9.999 ms
2 gige-g3-4.core1.chi1.he.net (2001:470:0:6e::1) 9.999 ms 10 ms 9.999 ms
3 10gigabitethernet3-2.core1.den1.he.net (2001:470:0:1af::2) 29.999 ms 29.998 ms 49.997 ms
4 10gigabitethernet4-4.core1.sjc2.he.net (2001:470:0:1b4::1) 49.997 ms 69.996 ms 59.997 ms
5 10gigabitethernet3-2.core1.pao1.he.net (2001:470:0:32::2) 59.996 ms 69.996 ms 49.997 ms
6 * * *
7 * * *
@bortzmeyer
bortzmeyer / gist:1034590
Created June 19, 2011 18:50
Notes about the INS project http://changaco.net/ins/
Terminology : why "registrar"? From the description, it is a registry.
Requirements: apparently, no explicit list of requirments, no specific
list of flaws identified in DNS or in other projects.
Why only one registry? This will make it the focus of many attacks,
technical and political. Anyway, I'm ultra-skeptic about this idea of
an ideal registry which can be trusted. Too much concentration of
power. That's the biggest problem with INS.
@bortzmeyer
bortzmeyer / gist:1053921
Created June 29, 2011 14:19
Apache configuration to handle differently IPv4 and IPv6 clients
LogFormat "[%h]:%{remote}p %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %v" combinedv6
LogFormat "%h:%{remote}p %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %v" combinedv4
SetEnvIf Remote_Addr : remote-v6
CustomLog /var/log/apache2/access.log combinedv6 env=remote-v6
CustomLog /var/log/apache2/access.log combinedv4 env=!remote-v6
@bortzmeyer
bortzmeyer / gist:1054920
Created June 29, 2011 20:49
Problème de status.net
status.net ne permet pas de vraie fédération car il n'existe pas de mécanisme d'identificateur
unique. Si deux personnes lancent une instance de status.net et se nomment "jean", ils ne pourront
pas connecter leurs instances car l'identificateur "jean" sera ambigu. Et s'ils se connectent
ensuite à identi.ca et que celui-ci a aussi un "jean", même problème.
De ce point de vue, status.net est en retard sur XMPP (où l'identificateur est nom@domaine et est
donc unique dans tout l'Internet) et même par rapport au courrier électronique qui a ce système
d'identificateurs fédérés depuis quarante ans  !
> est-ce utile de mettre à la fois "ip4:ip.du.server.master", "a" et "a:mail.example.tld" si tous
> pointent sur la même machine ?
Cela peut servir en cas de changement de configuration. Des tas de gens ont mis des beaux enregistrements SPF, les ont oublié, et ont tout cassé en changeant une adresse IP. Toujours penser au futur !
> y a t-il une nécessité de mettre "mx:antispam.tld" si cette machine ne fait que recevoir
> des messages (je ne pense pas).
Non, je ne vois en effet pas de raison de le mettre.
@bortzmeyer
bortzmeyer / gist:1086392
Created July 16, 2011 14:16
Resolve names, using the standard library (so, going through NSS and things like that, unlike dig)
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <errno.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip6.h>
@bortzmeyer
bortzmeyer / gist:1107878
Created July 26, 2011 20:10
Disneytek/Free downloaded file
DIVX0929<?xml version="1.0" encoding="UTF-8"?>
<cduparameterGenerator:CallParameters xmlns:cduparameterGenerator="com.divx.util.parame
terGenerator." skip="false"><cduparameterGenerator:Parameter name="nullParam000" paramN
ame="fileType" value="Ticket" /><cduparameterGenerator:Parameter name="nullParam001" pa
ramName="fileTypeVersion" value="2.1" /><cduparameterGenerator:Parameter name="nullPara
m002" paramName="ticket" value="PaCWvsfAihIUUMQAvTnkOz7_MlMerylX-1311710199895" /><cdup
arameterGenerator:Parameter name="nullParam003" paramName="title" value="Alice au Pays
des Merve illes" /><cduparameterGenerator:Parameter name="nullParam004" paramName="cont
entId" value="1252451" /><cduparameterGenerator:Parameter name="nullParam005" paramName
="dpcPlaybackAllowedInd" value="true" /><cduparameterGenerator:Parameter name="nullPara
@bortzmeyer
bortzmeyer / gist:1177172
Created August 28, 2011 20:22
My response to the questionnaire about the future of UTC
After reading the two excellent papers mentioned as reference, and after discussing the matter with several persons, I tend to think that the fundamental problem is the existence of several user communities, each with different (but perfectly legitimate) requirments. Because these requirments are different, there is zero chance to find a way to satisy them all with one time scale. The only solution is therefore to have several scales and to let each community choose the one which fits its requirments.
Of course, there are already several time scales. I feel that most of the needs of people who want the end of leap seconds would be satisfied by TAI (a very regular time scale, without "steps" and without link with the solar time). If, for one reason ot the other, TAI is not perfect for them, and there is no existing time scale suitable, it may be interesting to develop a new time scale (I'm not convinced it will be necessary: many proposals, such as the one for the "new UTC", are YATSCOT - "Yet Another Time Sc