Skip to content

Instantly share code, notes, and snippets.

View gist:bd59898bdd020494fdd7
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
}
View RawRepresentable-Equatable.swift
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 Oct 5, 2020
RainCclok - a hacky weather/time display for RaspiZeroW
View rainclok.py
#!/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