Skip to content

Instantly share code, notes, and snippets.

View giampaolo44's full-sized avatar

Giampaolo Ferradini giampaolo44

View GitHub Profile
@giampaolo44
giampaolo44 / turnCodeIntoHtml.py
Last active April 8, 2018 23:36
Turn a snippet or a piece of code into something that can be pasted and displayed into an html page
View turnCodeIntoHtml.py
"""
Turn a piece of python code into an html piece that respects indentation and CR.
input: fileName, [default = code_file]
output: fileName, [default = HtmlCode.html]
file_type: file_type, [default = txt]
"""
import argparse
parser = argparse.ArgumentParser(description="Crea l'html di un file di codice.")
parser.add_argument('-i', metavar='input_file', type=str, default="code_file") #input_file name
@giampaolo44
giampaolo44 / mcd.py
Last active October 1, 2016 16:24
minimo comune denominatore
View mcd.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 1 16:08:20 2016
@author: giampaolo
"""
def gcdRecur(a, b):
'''
View gmail_filters_xml.py
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import xml.etree.ElementTree as ET #import the xml library ElementTree
def getProperties(entry, ns): #function to find if it is being trashed and/or forwarded
for app_property in entry.findall('apps:property', ns):
name = app_property.attrib['name']
if name in ('forwardTo', 'shouldTrash'):
yield name
View gist:42b2d2757d5abfff5801b4b58e79b5c2
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import xml.etree.ElementTree as ET
def getProperties(entry, ns):
for app_property in entry.findall('apps:property', ns):
name = app_property.attrib['name']
if name in ('forwardTo', 'shouldTrash'):
yield name
@giampaolo44
giampaolo44 / legal.md
Last active August 1, 2016 15:19
Pagina Legal blog KJ
View legal.md
View gist:55b590b7cb9271cc55e5bbd5f6ef3413
#!/usr/bin/python
# coding=utf-8
import xml.etree.ElementTree as etree #importa la libreria per xml
tree = etree.parse('test_py-mailFilters.xml') #fa il parsing del file xml
root = tree.getroot() #lo prende tutto
entries = root.findall('{http://www.w3.org/2005/Atom}entry') #poi estrae solo le entries
contatore =0
for el in entries: #per ogni elemento 'entry' dell'xml