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 struct CoreGraphics.CGSize | |
import struct CoreGraphics.CGPoint | |
import struct CoreGraphics.CGFloat | |
extension CGSize: SIMD { | |
public typealias MaskStorage = SIMD2<CGFloat.NativeType.SIMDMaskScalar> | |
public subscript(index: Int) -> CGFloat { | |
get { | |
index == 0 ? width : height |
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 Combine | |
import CoreData | |
import Foundation | |
class CDPublisher<Entity>: NSObject, NSFetchedResultsControllerDelegate, Publisher where Entity: NSManagedObject { | |
typealias Output = [Entity] | |
typealias Failure = Error | |
private let request: NSFetchRequest<Entity> | |
private let context: NSManagedObjectContext |
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 Combine | |
import CoreData | |
public final class FetchedResultsPublisher | |
<ResultType> | |
: Publisher | |
where | |
ResultType: NSFetchRequestResult | |
{ | |
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
extension UIImage { | |
/// Returns cost for the given image by approximating its bitmap size in bytes in memory. | |
/// SEE ALSO: https://github.com/kean/Nuke/blob/master/Sources/ImageCache.swift | |
var cost: Int { | |
// bytesPerRow * height gives a rough estimation of how much memory | |
// image uses in bytes. In practice this algorithm combined with a | |
// concervative default cost limit works OK. | |
guard let cgImage = self.cgImage else { | |
return 1 |
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
# Useful for improving Time Machine backup prep. times, Mac App Store install speeds, etc. | |
sudo sysctl debug.lowpri_throttle_enabled=0 | |
# To restore defaults | |
sudo sysctl debug.lowpri_throttle_enabled=1 |
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
extension String { | |
func convertAttributedString() -> NSAttributedString?{ | |
let html = self._removePT() | |
let encoded = html.data(using: String.Encoding.utf8)! | |
let attributedOptions : [NSAttributedString.DocumentReadingOptionKey : Any] = [ | |
.documentType : NSAttributedString.DocumentType.html, | |
.characterEncoding : String.Encoding.utf8.rawValue | |
] | |
do { | |
let attributedTxt = try NSAttributedString(data: encoded, options: attributedOptions, documentAttributes: nil) |
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
package com.asdev.bin2img | |
import java.awt.Color | |
import java.awt.image.BufferedImage | |
import java.io.ByteArrayOutputStream | |
import java.io.File | |
import java.nio.file.Files | |
import javax.imageio.ImageIO | |
/** |
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
// | |
// ObjcViewController.m | |
// FilterCam | |
// | |
// Created by B Gay on 11/3/17. | |
// Copyright © 2017 B Gay. All rights reserved. | |
// | |
#import "ObjcViewController.h" | |
#import <AVFoundation/AVFoundation.h> |
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
/* | |
Thanks for @olebegemann | |
code of keypath from this link | |
https://oleb.net/blog/2017/01/dictionary-key-paths/ | |
*/ | |
struct KeyPath { | |
var segments: [String] | |
var isEmpty: Bool { return segments.isEmpty } |