Skip to content

Instantly share code, notes, and snippets.

View trunet's full-sized avatar

Wagner Sartori Junior trunet

View GitHub Profile
@trunet
trunet / reformat_country_for_iso_currency_matching.py
Created July 31, 2024 04:26
Function to fix and match ISO 3166 country names with ISO 4217 currency country names
import re
# Some use cases from the XML ISO 4217 vs ISO 3166 json
LIST_OF_COUNTRIES = {
"KOREA (THE DEMOCRATIC PEOPLE’S REPUBLIC OF)": "Korea, Democratic People's Republic of",
"KOREA (THE REPUBLIC OF)": "Korea, Republic of",
"UNITED STATES OF AMERICA (THE)": "United States of America",
"CONGO (THE DEMOCRATIC REPUBLIC OF THE)": "Congo, Democratic Republic of the",
"BOLIVIA (PLURINATIONAL STATE OF)": "Bolivia, Plurinational State of",
"COCOS (KEELING) ISLANDS (THE)": "Cocos (Keeling) Islands",
@trunet
trunet / low-battery-level-detection-notification-for-all-battery-sensors.yaml
Last active July 12, 2022 22:11 — forked from sbyx/low-battery-level-detection-notification-for-all-battery-sensors.yaml
Home Assistant Blueprint: Low battery level detection & notification for all battery sensors
blueprint:
name: Low battery level detection & notification for all battery sensors
description: Regularly test all sensors with 'battery' device-class for crossing
a certain battery level threshold and if so execute an action.
domain: automation
input:
threshold:
name: Battery warning level threshold
description: Battery sensors below threshold are assumed to be low-battery (as
well as binary battery sensors with value 'on').
@trunet
trunet / graphql-go-mongodb-example.go
Created June 18, 2018 13:28 — forked from aquiseb/graphql-go-mongodb-example.go
Minimal example of GraphQL Golang and MongoDB playing nicely together. Edit
// Embedded in this article https://medium.com/p/c98e491015b6
package main
import (
"context"
"fmt"
"log"
"net/http"
"time"

Keybase proof

I hereby claim:

  • I am trunet on github.
  • I am trunet (https://keybase.io/trunet) on keybase.
  • I have a public key whose fingerprint is 5946 5C07 204D 1B96 DBF1 E042 B7A1 D8AA 43C3 DD4E

To claim this, I am signing this object:

### Keybase proof
I hereby claim:
* I am trunet on github.
* I am trunet (https://keybase.io/trunet) on keybase.
* I have a public key whose fingerprint is 26D0 1144 D4DC 41B1 5A59 A4D4 5C57 B51B 2A09 4EBB
To claim this, I am signing this object:
@trunet
trunet / protocol.py
Last active January 6, 2021 00:56
NTP protocol for Twisted using ntplib
from twisted.internet.protocol import DatagramProtocol
from twisted.python import log
from twisted.python.failure import Failure
from ntplib import *
import time
class Error(Exception): pass
class TimeoutError(Error): pass