Skip to content

Instantly share code, notes, and snippets.

View seanlilmateus's full-sized avatar

Mateus seanlilmateus

View GitHub Profile
@seanlilmateus
seanlilmateus / ManagedObjectChangesPublisher.swift
Created January 23, 2022 16:37 — forked from mjm/ManagedObjectChangesPublisher.swift
Observe changes to a Core Data fetch request with Combine
import Combine
import CoreData
extension NSManagedObjectContext {
func changesPublisher<Object: NSManagedObject>(for fetchRequest: NSFetchRequest<Object>)
-> ManagedObjectChangesPublisher<Object>
{
ManagedObjectChangesPublisher(fetchRequest: fetchRequest, context: self)
}
}
@seanlilmateus
seanlilmateus / AutoGrowingTextField.swift
Created January 18, 2022 13:02 — forked from takuoka/AutoGrowingTextField.swift
Example of an NSTextField that expands its height automatically. https://github.com/DouglasHeriot/AutoGrowingNSTextField
import Cocoa
// https://github.com/DouglasHeriot/AutoGrowingNSTextField
// for AutoLayout
class AutoGrowingTextField: NSTextField {
var minHeight: CGFloat? = 100
import CoreData
/// Manages Core Data Persistent History.
///
/// When using Core Data in multiple targets, e.g. an app as well as a file provider, it is crucial to merge changes from one
/// target into another because otherwise you would end up with inconsistent state. To that end, this Apple introduced
/// persistent history, which is a linear stream of changes that can be merged into the current context. This service takes
/// advantage of this feature by providing a simple interface for merging and deleting history. The latter is needed to free up
/// space after the history has been consumed by all targets. It uses history transactions' timestamps in order to determine
/// what to delete.
@seanlilmateus
seanlilmateus / BlurredHostingController.swift
Created January 8, 2022 22:57 — forked from Ash-Bash/BlurredHostingController.swift
Creates a UIViewController with Blurred Background Which acts like a UIHostingController for SwiftUI Views (Useful for UIKit developers using SwiftUI Views for Modal Views)
//
// BluredBackgroundHostingController.swift
// v1.0.1
//
// Created by Ashley Chapman on 07/04/2020.
// Copyright © 2020 Ashley Chapman. All rights reserved.
//
import UIKit
@seanlilmateus
seanlilmateus / FetchedResultsControllerPublisher.swift
Created January 7, 2022 20:46 — forked from josephlord/FetchedResultsControllerPublisher.swift
Making a Combine publisher from a FetchedResultsController
//
// FetchedResultsControllerPublisher.swift
// ListsModel
//
// Created by Joseph Lord on 09/06/2019.
// Copyright © 2019 Joseph Lord. All rights reserved.
//
import Foundation
import Combine
@seanlilmateus
seanlilmateus / InnerShadowsDemo.swift
Created January 2, 2022 19:50 — forked from CodeSlicing/InnerShadowsDemo.swift
Source-code for CodeSlicing Episode on inner-shadows
//
// InnerShadowsDemo.swift
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
@seanlilmateus
seanlilmateus / SHA256-Bridging-Header.h
Created December 10, 2021 23:07 — forked from hfossli/SHA256-Bridging-Header.h
AES 256 in swift 4 with CommonCrypto
#import <CommonCrypto/CommonCrypto.h>
@seanlilmateus
seanlilmateus / apache2_HPKP.md
Created October 9, 2021 05:46 — forked from GAS85/apache2_HPKP.md
Activating HTTP Public Key Pinning (HPKP) on Let's Encrypt

Activating HTTP Public Key Pinning (HPKP) on Let's Encrypt

Source: https://lilleengen.io/blog/index.php/posts/activating-http-public-key-pinning-hpkp-on-lets-encrypt

  • Disclaimer: This might break your website, don't preceded if you don't know what you're doing.

Since the letsencrypt seems to create a new private key every time the certificate is renewed and Let's Encrypt requires you to renew you certificate once every ~80 days pinning using your certificate's SPKI is probably not the way to go. So, what should we pin then? Let's Encrypt is currently issuing from Authority X3, and using Authority X4 as a backup, so these two is a great place to start. We should also include the ISRG Root so this might support new Authorities with other SPKIs as well.

Generate HASH of Private Keys

To generate the hash of the SPKI of these certificates run the following commands

Features and Step Definitions

Gherkin Keywords

  • Feature
  • Background
  • Scenario
  • Given
  • When
  • Then
  • And