Skip to content

Instantly share code, notes, and snippets.

# coding: utf-8
__author__ = 'Mário Antunes'
__version__ = '1.0'
__email__ = 'mario.antunes@ua.pt'
__status__ = 'Production'
__license__ = 'MIT'
import sys
@dgomes
dgomes / snakes.py
Created December 5, 2021 22:30
Barebone snake game
import pygame
import random
WIDTH, HEIGHT = 80, 40
SCALE = 10
display = pygame.display.set_mode((SCALE * WIDTH, SCALE * HEIGHT))
clock = pygame.time.Clock()
snake_body = [(40, 20), (39, 20), (38, 20)]
@dgomes
dgomes / example_mc.py
Created June 28, 2021 21:06
Python3 multicast socket with selectors example
import socket
import struct
import random
import selectors
MY_ID = random.randint(0, 100)
MC_GROUP = "224.0.0.69"
MC_PORT = 10000
69d26f23df3fcd20e5c49f0922c5eaf1 test_basic.py
3ded307291ecde060cb9866fd8ead4e2 test_broker.py
f9bea53cee19cc86e5ca5d1980bd9c4e test_subtopic.py
5920976c1a94e9b5cdbfb767865851b9 test_wire.py
d41d8cd98f00b204e9800998ecf8427e __init__.py
f1d14f77e933b74e6d11eb00ab4ab9a9 test_basic.py
5e978cf20e8018ea68adf3b063f8e45a test_dynamic.py
e76de97998d3f44c189b18e215ef292e test_finger_table.py
113413113d7776722592ae6f471825bf test_utils.py
d41d8cd98f00b204e9800998ecf8427e __init__.py
c4cf028e242ddcd5b3736bb12beb1c8b test_basic.py
55a5a817db13595189232df95ff417f8 test_protocol.py
fdf7a2e47d8367a373f8e607110ed007 test_server.py
@dgomes
dgomes / ttn_client_app.py
Last active December 23, 2020 16:28
TTN Example App
import paho.mqtt.client as mqtt
import base64
import json
server = "eu.thethings.network"
up_topic = '+/devices/+/up'
user = "my_user" #Application ID
password = "ttn-account-v2.verycrazystring" #Application Access Key
def on_message(mqttc, obj, msg):
@dgomes
dgomes / translation.py.diff
Created January 14, 2019 23:18
Possible patch
--- a/homeassistant/helpers/translation.py
+++ b/homeassistant/helpers/translation.py
@@ -4,7 +4,7 @@ from os import path
from typing import Any, Dict, Iterable
from homeassistant import config_entries
-from homeassistant.loader import get_component, bind_hass
+from homeassistant.loader import get_component, get_platform, bind_hass
from homeassistant.util.json import load_json
from .typing import HomeAssistantType
@dgomes
dgomes / open_webloc.sh
Created January 4, 2019 14:32
Open OSX .webloc files in Linux
#!/usr/bin/env bash
# Based on https://blog.scottlowe.org/2016/12/21/opening-webloc-files-ubuntu/
if ! [ $(command -v xmllint) ]; then
echo "xmllint not installed"
exit
fi
if ! [ $(command -v plistutil) ]; then
echo "plistutil not installed"
@dgomes
dgomes / HeatingMonitorYun.ino
Last active November 13, 2019 01:24
Monitoring Hot Sanitary Water Storage with an Arduino Yun
#include <Arduino.h>
#define LCD
#define ONEWIRE_PIN 2
#define PUMP_PIN 3
#ifdef CONSOLE
#include <Console.h>
#endif
#ifdef LCD