This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sqlalchemy | |
| from sqlalchemy import create_engine, MetaData, Table, Column, String, Integer, inspect, text | |
| from sqlalchemy.exc import SQLAlchemyError | |
| import re | |
| # --- Configurazione --- | |
| DB_USER = "root" | |
| DB_PASS = "root" | |
| DB_HOST = "localhost" | |
| DB_PORT = "3306" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import csv | |
| f = open('../data/data_cad.json') | |
| rows = json.load(f) | |
| previous_article = {} | |
| with open('../data/gitdiff.csv', mode='w') as csv_file: | |
| fieldnames = ['data', 'articolo', 'type','no','size_article'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| from pydub import AudioSegment | |
| rain = AudioSegment.from_file("../sounds/rain_background.wav", format="wav") | |
| wind = AudioSegment.from_file("../sounds/wind.mp3", format="mp3") | |
| thunder = AudioSegment.from_file("../sounds/thunder.wav", format="wav") | |
| bird = AudioSegment.from_file("../sounds/bird.mp3", format="mp3") | |
| df=pd.read_csv('../data/gitdiff.csv') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from music21 import converter,instrument | |
| s = converter.parse('../sounds/cad-piano.mid') | |
| for p in s.parts: | |
| p.insert(0, instrument.Violin()) | |
| s.write('midi', '../sounds/cad-violino.mid') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import partitura.score as score | |
| import partitura | |
| import pandas as pd | |
| part = score.Part('P0', 'Piano', quarter_duration=1250) | |
| source =pd.read_csv('../data/gitdiff.csv') | |
| first_song = source[source['data']=='2005-03-07'] | |
| len_song = first_song.shape[0] | |
| half_len = int(len_song/2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "date": "2021-12-10T16:07:20.881173+01:00", | |
| "url": "https://www.unime.it", | |
| "hosting_green": false, | |
| "co2_grams": 2.3048954692203547, | |
| "energy_kWh": 0.004852411514148116, | |
| "water_litres": 1.2819828599803613, | |
| "resources": { | |
| "transfer_size_bytes": { | |
| "total": 3823256, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [GREENWEB] | |
| GREENWEB_PATH = /Users/giovanni/projects/carbon-calculator/data/green_urls.db | |
| [LIGHTHOUSE] | |
| LIGHTHOUSE_PATH = /Users/giovanni/.nvm/versions/node/v14.17.6/bin/lighthouse |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| carbon-cli -h | |
| usage: carbon-cli [-h] -db GREENWEB [-lh LIGHTHOUSE] website | |
| Carbon Calculator - the tool calculates the carbon emissions (CO2) and green infos of any website | |
| positional arguments: | |
| website The URL to analyze | |
| optional arguments: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from carbon.calculator import CarbonCalculator | |
| carbon = CarbonCalculator.from_ini_file('config.ini') | |
| carbon.footprint("https://www.unime.it") | |
| print(carbon.co2_grams) | |
| //0.29566587414592505 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from carbon.calculator import CarbonCalculator | |
| from carbon.services import LighthouseService, GreenWebService | |
| # If lighthouse tool is installed globally the following row can be omitted | |
| lighthouse = LighthouseService(lighthouse = PATH_OF_LIGHTHOUSE_TOOL) | |
| # It loads the Green Web Dataset DB (must be a SQL3Lite file) | |
| greenweb = GreenWebService(greenweb = PATH_OF_GREEN_DB) | |
| # It calculates CO2 emissions |
NewerOlder