Skip to content

Instantly share code, notes, and snippets.

View dimebt's full-sized avatar
🎯
Focusing

Dimitar Stefanovski dimebt

🎯
Focusing
View GitHub Profile
@dimebt
dimebt / CertificatePinning.swift
Created January 29, 2023 21:40 — forked from pallavtrivedi03/CertificatePinning.swift
Implementation of SSL pinning (using certifcate)
func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
guard let serverTrust = challenge.protectionSpace.serverTrust else {
completionHandler(.cancelAuthenticationChallenge, nil);
return
}
let certificate = SecTrustGetCertificateAtIndex(serverTrust, 0)
// SSL Policies for domain name check
let policy = NSMutableArray()
@dimebt
dimebt / docker_commands.sh
Last active May 22, 2023 13:46
Basic docker shell commands
# Docker commands
# Show all containers (default shows just running)
docker ps -a
# Start the docker service
systemctl start docker
# List images
docker images
struct ContentView: View {
@State var transactionId: String = "Not set yet!"
var body: some View {
NavigationView {
WWidgetPreview(transaction: Helper.getTransaction(from: transactionId))
.onOpenURL(perform: { (transactionId) in
self.transactionId = transactionId.absoluteString
})
ForEach(self.transactions, id: \.self) { transaction in
Link(destination: URL(string: transaction.stringId)!) {
VStack {
HStack {
struct Provider: TimelineProvider {
public typealias Entry = WalletWidgetEntry
public func placeholder(in context: Context) -> Entry {
let entry = WalletWidgetEntry(date: Date())
return entry
}
}
public func timeline(with context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
// Generate a timeline consisting of one entry with reload policy after 1 min.
let currentDate = Date()
let nextUpdateDate = Calendar.current.date(byAdding: .minute,
value: 1,
to: currentDate)!
let entry = WalletWidgetEntry(date: currentDate)
let timeline = Timeline(entries: [entry], policy: .after(nextUpdateDate))
completion(timeline)
public func snapshot(with context: Context, completion: @escaping (WalletWidgetEntry) -> ()) {
let entry = WalletWidgetEntry(date: Date())
completion(entry)
}
struct WalletWidgetEntryView : View {
var entry: Provider.Entry
@Environment(\.widgetFamily) var family
@ViewBuilder
var body: some View {
//Text(entry.date, style: .time)
switch family {
case .systemSmall:
@main
struct WalletWidget: Widget {
private let kind: String = "WalletWidget"
public var body: some WidgetConfiguration {
StaticConfiguration(kind: kind, provider: Provider()) { entry in
WalletWidgetEntryView(entry: entry)
}
.configurationDisplayName("Wallet Widget")
.description("Description for the Wallet app widget.")
let backgroundQueue = DispatchQueue.global(qos: .background)
firstly {
showLoader()
}.then(on: backgroundQueue) {
self.fetchJSON()
}.then(on: backgroundQueue) { (photos) in
self.downloadPhotos(photos: Array(photos.prefix(40)))
}.done(on: DispatchQueue.main, flags: nil) { _ in
self.hideLoader()