Skip to content

Instantly share code, notes, and snippets.

View enzosterro's full-sized avatar

Enzo Sterro enzosterro

  • Thomson Reuters
View GitHub Profile
@enzosterro
enzosterro / swiftui.swift
Last active June 12, 2019 08:39
How to update a single child view in SwiftUI?
class CustomColor: BindableObject {
var didChange = PassthroughSubject<CustomColor, Never>()
let id = UUID()
var color: Color {
didSet {
self.didChange.send(self)
}
}
@enzosterro
enzosterro / tr_led.py
Last active August 18, 2018 16:08
Telegram Bot + Transmission Raspberry Pi LED indication
#!/usr/bin/env python
import RPi.GPIO as GPIO
import transmissionrpc
import time
import sys
import os
class Led:
@enzosterro
enzosterro / .bash_profile
Last active December 14, 2017 08:28
Record Simulator Video
simrecord() {
read -p "Enter file name:" filename
xcrun simctl io booted recordVideo ~/Downloads/$filename.mov
}
@enzosterro
enzosterro / UniqueElements.swift
Last active September 21, 2017 09:10
Extension to Count Unique Elements in Array
extension Array where Element: Comparable {
var uniqueElements: Int {
let sorted = self.sorted(by: <)
let initial: (Element?, Int) = (.none, 0)
let counter = sorted.reduce(initial) { ($1, $0.0 == $1 ? $0.1 : $0.1 + 1) }
return counter.1
}
}