Skip to content

Instantly share code, notes, and snippets.

@aws-amplify-ops
aws-amplify-ops / cleanup-steps.md
Last active August 31, 2023 19:51
Steps for cleaning user data for owner based auth schema

Who is this Gist for?

This Gist demonstrates an approach to removing a specific user's data from an Amazon DynamoDB table that was created as an AWS AppSync data source. It may be helpful for those who need to remove records that are associated with a Cognito User that will be deleted from their Cognito User Pool.

Steps to clean up user data

Clean up user data with DataStore disabled (conflict resolution disabled)

Assuming you have this schema

@hishnash
hishnash / ExampleWindowReaderApp.swift
Created December 21, 2020 05:59
Access to the underlying UIWindow & NSWindow in swiftUI gives access to window methods and attributes.
//
// ExampleWindowReaderApp.swift
// Shared
//
// Created by Matthaus Woolard on 21/12/2020.
//
import SwiftUI
@main
@ts95
ts95 / CLLocationCoordinate2D+Midpoint.swift
Last active January 27, 2024 01:35
CLLocationCoordinate2D + midpoint function extension
import Foundation
import CoreLocation
// based on https://gis.stackexchange.com/a/18740
extension CLLocationCoordinate2D {
var cartesian: CartesianCoordinate3D { .init(from: self) }
// Returns the coordinates of the midpoint between point a and b.
// Limitation: point a and b may not be diametrically opposite.
@mecid
mecid / PagerView.swift
Last active August 15, 2024 06:38
PagerView in SwiftUI
//
// PagerView.swift
//
// Created by Majid Jabrayilov on 12/5/19.
// Copyright © 2019 Majid Jabrayilov. All rights reserved.
//
import SwiftUI
struct PagerView<Content: View>: View {
let pageCount: Int
@dionc
dionc / MapKitExtensions.swift
Last active June 26, 2024 13:43
Create an MKCoordinateRegion from an array of coordinates. Safely handles coordinates that cross the 180th meridian.
import MapKit
extension MKCoordinateRegion {
init?(coordinates: [CLLocationCoordinate2D]) {
// first create a region centered around the prime meridian
let primeRegion = MKCoordinateRegion.region(for: coordinates, transform: { $0 }, inverseTransform: { $0 })
// next create a region centered around the 180th meridian
@steipete
steipete / ios-xcode-device-support.sh
Last active September 16, 2024 18:26
Using iOS 15 devices with Xcode 12.5 (instead of Xcode 13)
# The trick is to link the DeviceSupport folder from the beta to the stable version.
# sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :)
# Support iOS 15 devices (Xcode 13.0) with Xcode 12.5:
sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/15.0 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
# Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions
# (A similar approach works for older versions too, just change the version number after DeviceSupport)
@nakiostudio
nakiostudio / UpdateRealmObject.swift
Last active June 25, 2019 14:04
Make RealmSwift write and update an Object keeping the existing relationships
/**
Writes a set of objects in the database.
- parameter objects: Array of `Objects` to be stored on the database
- parameter configuration: Realm `Configuration` in which the write action will be performed
- parameter update: Enabled the custom *update* maintaining existing relationships
*/
static func write(objects : [Object], configuration: Realm.Configuration, update: Bool = false) {
if let realm = try? Realm(configuration: configuration) {
realm.beginWrite()
@AliSoftware
AliSoftware / struct_vs_inheritance.swift
Last active March 27, 2024 11:57
Swift, Struct & Inheritance: How to balance the will of using Struct & Value Types and the need for Inheritance?
// #!Swift-1.1
import Foundation
// MARK: - (1) classes
// Solution 1:
// - Use classes instead of struct
// Issue: Violate the concept of moving model to the value layer
// http://realm.io/news/andy-matuschak-controlling-complexity/
@foozmeat
foozmeat / openssl-build.sh
Last active May 22, 2024 17:56
A shell script to build openssl for iOS and Mac. It currently builds: Mac -> i386 & x86_64 // iOS -> armv7, arm64 // iOS Simulator -> i386 & x86_64.
#!/bin/bash
# This script builds the iOS and Mac openSSL libraries
# Download openssl http://www.openssl.org/source/ and place the tarball next to this script
# Credits:
# https://github.com/st3fan/ios-openssl
# https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh