Skip to content

Instantly share code, notes, and snippets.

View IvanovDeveloper's full-sized avatar

Andrew Ivanov IvanovDeveloper

  • Ukraine
View GitHub Profile
@krodak
krodak / Realm+CascadeDeleting.swift
Last active April 27, 2023 19:16
Cascade deletion for RealmSwift
import RealmSwift
import Realm
protocol CascadeDeleting: class {
func delete<Entity>(_ list: List<Entity>, cascading: Bool)
func delete<Entity>(_ results: Results<Entity>, cascading: Bool)
func delete<Entity: Object>(_ entity: Entity, cascading: Bool)
}
@matthiasnagel
matthiasnagel / UIImageFixedOrientationExtension.swift
Created January 19, 2017 09:36 — forked from schickling/UIImageFixedOrientationExtension.swift
Extension to fix orientation of an UIImage (Sets orientation to portrait)
import UIKit
extension UIImage {
public func fixedOrientation() -> UIImage {
if imageOrientation == UIImageOrientation.up {
return self
}
@eleev
eleev / URLForPHAsset.swift
Last active February 17, 2024 23:56
Getting URL for PHAsset (Swift 3.0)
func getURL(ofPhotoWith mPhasset: PHAsset, completionHandler : @escaping ((_ responseURL : URL?) -> Void)) {
if mPhasset.mediaType == .image {
let options: PHContentEditingInputRequestOptions = PHContentEditingInputRequestOptions()
options.canHandleAdjustmentData = {(adjustmeta: PHAdjustmentData) -> Bool in
return true
}
mPhasset.requestContentEditingInput(with: options, completionHandler: { (contentEditingInput, info) in
completionHandler(contentEditingInput!.fullSizeImageURL)
})
@suraphanL
suraphanL / ioslocaleidentifiers.csv
Created October 5, 2016 15:29 — forked from JaseHadd/ioslocaleidentifiers.csv
iOS Locale Identifiers
localeIdentifier Description
eu Basque
hr_BA Croatian (Bosnia & Herzegovina)
en_CM English (Cameroon)
rw_RW Kinyarwanda (Rwanda)
en_SZ English (Swaziland)
tk_Latn Turkmen (Latin)
he_IL Hebrew (Israel)
ar Arabic
uz_Arab Uzbek (Arabic)
@stinger
stinger / Swift3Base64.swift
Created June 17, 2016 14:58
Swift 3: Base64 encoding and decoding strings
//: # Swift 3: Base64 encoding and decoding
import Foundation
extension String {
//: ### Base64 encoding a string
func base64Encoded() -> String? {
if let data = self.data(using: .utf8) {
return data.base64EncodedString()
}
return nil
@sigmaray
sigmaray / books.md
Last active October 31, 2017 01:41
Books

Список полезных книг

В списке только нехудожественные книги, которые я прочитал или полностью, или частично. Записаны не все прочитанные книги. Полный мусор, за который было стыдно после прочетния, не записывал.

@willthink
willthink / contact.m
Last active March 6, 2023 20:05
Using CNContactStore in Objective C to query contacts info
#import <Contacts/Contacts.h>
@implementation ContactsScan
- (void) contactScan
{
if ([CNContactStore class]) {
//ios9 or later
CNEntityType entityType = CNEntityTypeContacts;
if( [CNContactStore authorizationStatusForEntityType:entityType] == CNAuthorizationStatusNotDetermined)
@iandundas
iandundas / UIImagePickerController+cats.m
Created March 16, 2015 16:19
How to detect iOS Photo library or Camera permissions (>iOS8)
//
// Created by Ian Dundas on 16/03/15.
//
#import "UIImagePickerController+cats.h"
#import <AVFoundation/AVFoundation.h>
#import "Photos/Photos.h"
/*
example usage:
@imkevinxu
imkevinxu / Device.swift
Last active March 4, 2023 16:09
iOS device checks for OS version and screen size in Swift
//
// Device.swift
// imHome
//
// Created by Kevin Xu on 2/9/15. Updated on 6/20/15.
// Copyright (c) 2015 Alpha Labs, Inc. All rights reserved.
//
import Foundation
@kristopherjohnson
kristopherjohnson / utcDateTime.m
Last active December 8, 2017 12:31
Get UTC date/time string for current time using NSCalendar
NSDate *date = [NSDate date];
NSCalendar *utcCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
utcCalendar.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
unsigned ymdhmsUnitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay| NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
NSDateComponents *utcDateComponents = [utcCalendar components:ymdhmsUnitFlags fromDate:date];
// Create string of form "yyyy-mm-dd hh:mm:ss"