Skip to content

Instantly share code, notes, and snippets.

View atetlaw's full-sized avatar
💻
Working on something cool

Andrew Tetlaw atetlaw

💻
Working on something cool
View GitHub Profile
@florentmorin
florentmorin / DarwinNotificationCenter.swift
Last active November 29, 2022 21:51 — forked from AvdLee/DarwinNotificationCenter.swift
A notification center for Darwin Notifications. MIT License applies.
//
// DarwinNotificationCenter.swift
//
// Copyright © 2017 WeTransfer. All rights reserved.
//
// Source: https://gist.github.com/florentmorin/35b15837cd4fb2a2a0630dbdf41d09aa
// Original: https://gist.github.com/AvdLee/07de0b0fe7dbc351541ab817b9eb6c1c
import Foundation
@mecid
mecid / Calendar.swift
Last active May 5, 2024 08:43
SwiftUI Calendar view using LazyVGrid
import SwiftUI
extension Calendar {
func generateDates(
inside interval: DateInterval,
matching components: DateComponents
) -> [Date] {
var dates: [Date] = []
dates.append(interval.start)
//
// UIView+RSKeyboardLayoutGuide.swift
// RSTouchUIKit
//
// Created by Daniel Jalkut on 12/23/18.
//
import UIKit
// Extends UIView to expose a keyboardLayoutGuide property that can be used to tie a view controller's content
// Advanced SwiftUI Transitions
// https://swiftui-lab.com
// https://swiftui-lab.com/advanced-transitions
import SwiftUI
struct CrossEffectDemo: View {
let animationDuration: Double = 2
let images = ["photo1", "photo2", "photo3", "photo4"]
@State private var idx = 0
@tcldr
tcldr / TimingFunction.swift
Last active March 21, 2023 07:24
For when you need the progress along an Apple Animation curve outside of CoreAnimation in a Swift 4.2 interface. Given a cubic Bezier timing curve defined by two control points, (or UIKit's `UICubicTimingParameters`), returns the progress along the curve at any given time. Includes a port of the WebKit implementation of UnitBezier which hopefull…
//
// TimingFunction.swift
//
// Created by tcldr on 04/11/2018.
// https://github.com/tcldr
// Copyright © 2018 tcldr.
//
// Permission is hereby granted, free of charge,
// to any person obtaining a copy of this software and
// associated documentation files (the "Software"), to
@novemberfiveco-gists
novemberfiveco-gists / WKCookieWebView.swift
Last active June 26, 2023 10:02
A WKWebView subclass that passes cookies after a 302 redirect response.
//
// WKCookieWebView.swift
//
// Created by Jens Reynders on 30/03/2018.
// Copyright (c) 2018 November Five
//
// 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
@rl-pavel
rl-pavel / 1-Example.swift
Last active February 1, 2023 03:17
Localized Date Formatting
// US locale:
// Oct 14, 2020, 7:50 PM
Date().format(with: [.monthShort, .dayOfMonth, .yearFull, .hour, .minute], locale: Locale(identifier: "en_US"))!
// French locale:
// 14 Oct 2020 à 19:50
Date().format(with: [.monthShort, .dayOfMonth, .yearFull, .hour, .minute], locale: Locale(identifier: "fr"))!
@DougGregor
DougGregor / dynamic_member_lookup_environment.swift
Created May 2, 2018 16:59
Using Swift 4.2's @dynamicMemberLookup to expose environment variables
import Darwin
@dynamicMemberLookup
struct Environment {
subscript(dynamicMember name: String) -> String? {
get {
guard let value = getenv(name) else { return nil }
return String(validatingUTF8: value)
}
@Koze
Koze / TextDetection.m
Last active June 14, 2019 22:38
Text Detection with Vision Framework
- (void)detectWithImageURL:(NSURL *)URL
{
VNImageRequestHandler *handler = [[VNImageRequestHandler alloc] initWithURL:URL options:@{}];
VNDetectTextRectanglesRequest *request = [[VNDetectTextRectanglesRequest alloc] initWithCompletionHandler:^(VNRequest * _Nonnull request, NSError * _Nullable error) {
if (error) {
NSLog(@"%@", error);
}
else {
for (VNTextObservation *textObservation in request.results) {
// NSLog(@"%@", textObservation);
@fntlnz
fntlnz / self-signed-certificate-with-custom-ca.md
Last active May 6, 2024 08:45
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096