Skip to content

Instantly share code, notes, and snippets.

extension Array {
func toDict<K,V>(map: (Element) -> (K, V)?) -> [K: V] {
var dict = [K: V]()
for element in self {
if let (key, value) = map(element) {
dict[key] = value
}
}
return dict
}
func ==<U: Equatable, T: protocol<RawRepresentable, Equatable> where T.RawValue == U>(lhs: U, rhs: T) -> Bool {
return lhs == rhs.rawValue
}
func !=<U: Equatable, T: protocol<RawRepresentable, Equatable> where T.RawValue == U>(lhs: U, rhs: T) -> Bool {
return lhs != rhs.rawValue
}
@apocolipse
apocolipse / rainclok.py
Created October 5, 2020 00:00
RainCclok - a hacky weather/time display for RaspiZeroW
#!/usr/bin/env python3
# encoding=utf8
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtSvg import *
from datetime import datetime
import requests
import lxml.html