View UnsafePointer Converter.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Swift UnsafePointer converter | |
// Kaz Yoshikawa | |
// | |
// These code demonstrates how to convert swift pointers to the other forms of pointers. | |
// | |
// Source: | |
// Swift の Array やら ArraySlice やらポインタの変換まとめ | |
// https://qiita.com/Satachito/items/4c39c9b06304e4d86660 | |
// |
View Runtime.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Runtime.swift | |
// Swift Runtime [Swift 4] | |
// | |
// The MIT License (MIT) | |
// | |
// Copyright (c) 2016 Electricwoods LLC, Kaz Yoshikawa. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal |
View FileHandle+Z.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// FileHandle+Z.swift | |
// ZKit | |
// | |
// The MIT License (MIT) | |
// | |
// Copyright (c) 2016 Electricwoods LLC, Kaz Yoshikawa. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal |
View Hanlde not found error for AWS HEAD request.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// AWS-SDK-Swift | |
// | |
// When you need to find if error is caused by resource not found,rather than other type of errors | |
// such as network error or access permissions related error. This is how to find, if this error | |
// is cause of resource not found. | |
// | |
// Note: | |
// I don't want to spend time for this next time, so I paste code snippet here for my future reference | |
func processHeadRequest(s3client: S3Client, bucket: String, key: String) async throws { |
View Data+hexadecimal.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Data+Hexadecimal.swift | |
// | |
// The MIT License (MIT) | |
// | |
// Copyright (c) 2023 Electricwoods LLC, Kaz Yoshikawa. | |
// | |
// 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 |
View UIImage+color.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIImage { | |
convenience init(color: UIColor) { | |
let renderer = UIGraphicsImageRenderer(size: CGSize(width: 1, height: 1)) | |
let image = renderer.image { context in | |
context.cgContext.setFillColor(UIColor.blue.cgColor) | |
context.cgContext.fill(CGRect(x: 0, y: 0, width: 1, height: 1)) | |
} | |
guard let cgImage = image.cgImage else { fatalError() } |
View UIKit+swizzling.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIKit+swizzling.swift | |
// | |
// The MIT License (MIT) | |
// | |
// Copyright (c) 2022 Electricwoods LLC, Kaz Yoshikawa. | |
// | |
// 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 |
View MTLTexture+Z.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// MTLTexture+Z.swift | |
// ZKit | |
// | |
// The MIT License (MIT) | |
// | |
// Copyright (c) 2016 Electricwoods LLC, Kaz Yoshikawa. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal |
View Array+slice.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public extension Array { | |
func slice(count: Int) -> [some Collection] { | |
let n = self.count / count // quotient | |
let i = n * count // index | |
let r = self.count % count // remainder | |
let slices = (0..<n).map { $0 * count }.map { self[$0 ..< $0 + count] } | |
return (r > 0) ? slices + [self[i..<i + r]] : slices | |
} |
View Array+RunLength.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Array+RunLength.swift | |
// ZKit | |
// | |
// The MIT License (MIT) | |
// | |
// Copyright (c) 2020 Electricwoods LLC, Kaz Yoshikawa. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal |
NewerOlder