Skip to content

Instantly share code, notes, and snippets.

View pfote's full-sized avatar

Andreas Pfotenhauer pfote

  • Ypsilon.NET AG
  • Frankfurt
View GitHub Profile
@pfote
pfote / bot.py
Created November 23, 2012 08:41
my old bot.py
#!/usr/bin/env python
##################################################
# little programming exercise using twisted irc
# ibot is a infobot which whole purpose is to
# autorespond to a defined set of keywords with
# a stored phrase
# $Id: bot.py,v 1.4 2003/12/14 13:38:29 pfote Exp $
##################################################
@pfote
pfote / gist:3655665
Created September 6, 2012 12:18
postgres .. unique index on two fields
test=# create table j (id1 int, id2 int);
CREATE TABLE
test=*# create unique index idx_j on j(greatest(id1, id2), least(id1, id2));
CREATE INDEX
test=*# insert into j values (1,2);
INSERT 0 1
test=*# insert into j values (2,1);
ERROR:  duplicate key violates unique constraint "idx_j"