Skip to content

Instantly share code, notes, and snippets.

@TaLinh
TaLinh / Decode_Dynamic_Key.swift
Last active July 30, 2021 17:56
Decode JSON with dynamic key
import Foundation
let clientJSON = """
{
"clients": [
{
"name": "John",
"amount": 1000
},
{
class WeakObject<T: AnyObject>: Hashable {
private(set) weak var object: T?
let identifier: ObjectIdentifier
static func == (lhs: WeakObject<T>, rhs: WeakObject<T>) -> Bool {
return lhs.identifier == rhs.identifier
}
func hash(into hasher: inout Hasher) {
hasher.combine(identifier)
final class DeinitObserver {
private let key: String
private weak var target: AnyObject?
private let deinitHandler: () -> Void
deinit {
deinitHandler()
}
init(for target: AnyObject, deinitHandler: @escaping () -> Void) {
import Network
protocol ConnectionAttribute: Equatable {
init(path: NWPath)
}
class ConnectionObserver<T: ConnectionAttribute> {
var handler: ((T) -> Void)?
private var monitor: NWPathMonitor
struct MultiTypeDictionary<Root> {
private var dict: [PartialKeyPath<Root>: Any] = [:]
// Called for non-optional properties
subscript<Value>(keyPath: KeyPath<Root, Value>) -> Value? {
get { dict[keyPath] as? Value }
set { dict[keyPath] = newValue }
}
// Called for optional properties
@TaLinh
TaLinh / rdv_naturalisation.sh
Created January 16, 2024 20:26 — forked from vadimkantorov/rdv_naturalisation.sh
A Bash script to monitor naturalisation rendez-vous availability at Prefectures Bobigny, Nanterre. Consider renting one or several EC2 micro instances at Paris AWS data center to avoid bans.
# Usage:
# 1. Put in your email/SendGrid credentials or phone/Twilio credentials
# 2. Run as: "bash rdv_naturalisation.sh nanterre" or "bash rdv_naturalisation.sh bobigny" or "bash rdv_naturalisation.sh cre"
# 3. Get your RDV! The script will dump the HTML of the page and will continue execution even after the first RDV is found.
SENDGRID_BEARER_TOKEN='' # should start with "SG."
SENDGRID_EMAIL='' # put your e-mail here
TWILIO_SID='' # should start with "AC"
TWILIO_AUTH_TOKEN=''
TWILIO_FROM_NUMBER='' # put your Twilio Trial Phone Number here, should start with +