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
"""
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 1 16:08:20 2016
@author: giampaolo
"""
def gcdRecur(a, b):
'''
#!/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
#!/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
#!/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