Skip to content

Instantly share code, notes, and snippets.

View zoernert's full-sized avatar

Thorsten Zoerner zoernert

View GitHub Profile
@zoernert
zoernert / totalco2.js
Created September 16, 2021 22:36
Calculating total CO2 Emission of MailStats
let totalco=0;
for(let i=0;i<mailStats.length;i++) {
for(let j=0;j<mailStats[i].stats.length;j++) {
for (const [key, value] of Object.entries(mailStats[i].stats[j].metrics)) {
if(key == "blocks") totalco2+=1
if(key == "bounce_drops") totalco2+=2
if(key == "bounces") totalco2+=2
if(key == "clicks") totalco2+=2
if(key == "deferred") totalco2+=2
Metric CO2Eq
blocks 1
bounce_drops 2
bounces 2
clicks 2
deferred 2
delivered 20
invalid_emails 0
opens 10
processed 15
@zoernert
zoernert / sendgridstats.js
Created September 16, 2021 22:12
Retrieve Sendgrid Statistics
const sendgridAPIKey = 'YOUR_SENDGRID_API_KEY';
const fromDate = new Date(new Date().getTime() - (7*87600000)).toISOString().split('T')[0]; // last 7 days
const axios = require("axios");
// Retrieve Statistics from Sendgrid
const sendgridStatsResponds = await axios.get("https://sendgrid.com/v3/stats?start_date="+fromDate,{
headers: {
'content-type': 'application/json',
'Authorization': 'Bearer '+sendgridAPIKey
### Keybase proof
I hereby claim:
* I am zoernert on github.
* I am thorsten_zoerner (https://keybase.io/thorsten_zoerner) on keybase.
* I have a public key ASBw2XjGvKjX1N3bjppkXX8nOSCAiQytJsA0sqTFlJTDdQo
To claim this, I am signing this object:
### Keybase proof
I hereby claim:
* I am zoernert on github.
* I am thorstenzoerner (https://keybase.io/thorstenzoerner) on keybase.
* I have a public key ASAc7rKmzHWeWyFeq3a5o_S83EBgnW4ryLXjgnTX_3Pgzwo
To claim this, I am signing this object:
pragma solidity ^0.4.10;
/**
* StromDAO Business Objects
* ====================================================================
* Upper level business objects required for power delivery on a public
* energy distribution system. Defines PowerDelivery as digital asset
* used for transaction data and entities (roles) for master data.
*
* @author Thorsten Zoerner <thorsten.zoerner(at)stromdao.de)
**/
var StromDAONode = new require("./StromDAONode.js");
var node = new StromDAONode.Node({});
// Hole einen GWALink und schreibe einen Messwert
node.gwalink('0xBA2ef7bF8f21218c85c3399025E0d6D63632dc03').then(
function(gwalink) {
var reader_in = gwalink.reader_in;
var reader_out = gwalink.reader_out;
var myReading=new Date().getTime();
{"p01067":{"a":"27.7","g":"118.62"},"p01069":{"a":"27.7","g":"118.62"},"p01097":{"a":"27.7","g":"118.62"},"p01099":{"a":"27.7","g":"118.62"},"p01108":{"a":"27.7","g":"118.62"},"p01109":{"a":"27.7","g":"118.62"},"p01127":{"a":"27.7","g":"118.62"},"p01129":{"a":"27.7","g":"118.62"},"p01139":{"a":"27.7","g":"118.62"},"p01156":{"a":"27.7","g":"118.62"},"p01157":{"a":"27.7","g":"118.62"},"p01159":{"a":"27.7","g":"118.62"},"p01169":{"a":"27.7","g":"118.62"},"p01187":{"a":"26.13","g":"146.85"},"p01189":{"a":"27.7","g":"118.62"},"p01217":{"a":"27.7","g":"118.62"},"p01219":{"a":"27.7","g":"118.62"},"p01237":{"a":"27.7","g":"118.62"},"p01239":{"a":"27.7","g":"118.62"},"p01257":{"a":"27.7","g":"118.62"},"p01259":{"a":"27.7","g":"118.62"},"p01277":{"a":"27.7","g":"118.62"},"p01279":{"a":"27.7","g":"118.62"},"p01307":{"a":"27.7","g":"118.62"},"p01309":{"a":"27.7","g":"118.62"},"p01324":{"a":"27.7","g":"118.62"},"p01326":{"a":"27.7","g":"118.62"},"p01328":{"a":"27.7","g":"118.62"},"p01445":{"a":"24","g":"122.57"},"p01454":
@zoernert
zoernert / fs_blockchain_edifact.js
Created July 10, 2016 20:41
Sample Implementation for EDI style message exchange using Ethereum blockchain for transactions (log messages transferred) and IPFS for message content (encrypted)
/**
Simple file based EDI style message exchange using EDIchain
Will use the following folder structure:
out\ = Place EDI Messages as text files in here (required Recipient in UNB segment)
sent\ = Messages sent and documented in blockchain (filename will be Transaction ID_IPFS-Hash
in\edi = Received EDI Messages (text files)
in\meta = Meta files corresponding to EDI Messages.
@zoernert
zoernert / microdao.abi
Last active June 19, 2017 10:13
Micro DAO to create an EVU in Germany
[ { "constant": true, "inputs": [], "name": "name", "outputs": [ { "name": "", "type": "string", "value": "MicroDAO" } ], "type": "function" }, { "constant": false, "inputs": [], "name": "executeSpendingRequests", "outputs": [], "type": "function" }, { "constant": false, "inputs": [ { "name": "number_of_days", "type": "uint256" }, { "name": "requiredShares", "type": "uint256" } ], "name": "setDirectorLock", "outputs": [], "type": "function" }, { "constant": true, "inputs": [ { "name": "", "type": "uint256" } ], "name": "bookings", "outputs": [ { "name": "time", "type": "uint256" }, { "name": "funding", "type": "uint256" }, { "name": "spending", "type": "uint256" }, { "name": "counterpart", "type": "address" }, { "name": "text", "type": "string" } ], "type": "function" }, { "constant": false, "inputs": [], "name": "closeFunding", "outputs": [], "type": "function" }, { "constant": false, "inputs": [ { "name": "node", "type": "string" } ], "name": "setDirectorNode", "outputs": [], "type": "function" }, { "consta