Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Gonçalves danielgoncalves

  • Base4 Sistemas
  • Catanduva/SP
  • Twitter @spanazzi
View GitHub Profile
@danielgoncalves
danielgoncalves / buscarcep.py
Last active Aug 29, 2015
Exemplo de uso do webservice "Buscar CEP" (Python 2.7)
View buscarcep.py
# -*- coding: utf-8 -*-
#
# buscarcep.py
#
# Exemplo de uso do webservice http://buscarcep.com.br/
# Para Python 2.7
#
# Daniel Gonçalves <daniel@base4.com.br>
#
@danielgoncalves
danielgoncalves / logr.py
Last active Dec 13, 2015
Minimalist tool to search and list occurrences of unique exceptions in log files. The exceptions should be logged using the `exception` method.
View logr.py
# -*- coding: utf-8 -*-
#
# logr.py is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# logr.py is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@danielgoncalves
danielgoncalves / example.py
Created Sep 5, 2011
Validate an IPv4 address.
View example.py
def is_ip(value):
"""IP simple validation in response to blog post http://goo.gl/L9cKh"""
try:
bytes = [int(e) for e in value.split('.') if 0 <= int(e) <= 255)]
except ValueError:
return False
return len(bytes) == 4