Skip to content

Instantly share code, notes, and snippets.

🚀
Focusing

Alexander Khitev alexanderkhitev

🚀
Focusing
View GitHub Profile
View Decode Array<Any> and Dictionary<String, Any> Swift
import Foundation
// Inspired by https://gist.github.com/mbuchetics/c9bc6c22033014aa0c550d3b4324411a
struct JSONCodingKeys: CodingKey {
var stringValue: String
init?(stringValue: String) {
self.stringValue = stringValue
}
View gist:5700471d620ea9e77b62a93e326a0e11
import Foundation
import RealmSwift
import ObjectMapper
class RealmUser: Object, Mappable {
dynamic var id = "" // id
dynamic var phoneNumber = ""
dynamic var isMain = false
dynamic var userInfo: RealmUserInfo? = nil
View gist:4a6548ccff6ff7d99f47d41bbde1ac80
# xcode-version-bump.sh
# @desc Auto-increment the version number (only) when a project is archived for export.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Check the checkbox "Run script only when installing"
# 6. Drag the "Run Script" below "Link Binaries With Libraries"
# 7. Insure your starting version number is in SemVer format (e.g. 1.0.0)
@alexanderkhitev
alexanderkhitev / README.md
Created Jan 7, 2017 — forked from simenbrekken/README.md
Firebase NPM doesn't expose the token generator dependency
View README.md

There are some ways to fix this:

  1. Remove dependency and let users install it manually as needed, the token generator isn't really a hard dependency of Firebase anyway
  2. Expose the dependency from the firebase module:
    var Firebase = require('firebase')
        FirebaseTokenGenerator = Firebase.TokenGenerator
@alexanderkhitev
alexanderkhitev / ArrayTransform.swift
Created Dec 13, 2016 — forked from Jerrot/ArrayTransform.swift
Transform arrays with ObjectMapper to Realm's List type
View ArrayTransform.swift
// Based on Swift 1.2, ObjectMapper 0.15, RealmSwift 0.94.1
// Author: Timo Wälisch <timo@waelisch.de>
import UIKit
import RealmSwift
import ObjectMapper
import SwiftyJSON
class ArrayTransform<T:RealmSwift.Object where T:Mappable> : TransformType {
typealias Object = List<T>
@alexanderkhitev
alexanderkhitev / gist:93bee949907d4c482bb8d413800daeda
Last active Dec 4, 2017
isValidEmail string extension for swift 3
View gist:93bee949907d4c482bb8d413800daeda
var isValidEmail: Bool {
do {
let regex = try NSRegularExpression(pattern: "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}", options: .caseInsensitive)
return (regex.firstMatch(in: self, options: [], range: NSMakeRange(0, self.characters.count)) != nil)
} catch {
debugPrint(error.localizedDescription)
return false
}
}
View For Denis
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
View gist:f5b9d2a5686297fa188491bcc3fd1157
func cropRect() -> CGRect {
let cgImage = self.CGImage!
let context = createARGBBitmapContextFromImage(cgImage)
if context == nil {
return CGRectZero
}
let height = CGFloat(CGImageGetHeight(cgImage))
let width = CGFloat(CGImageGetWidth(cgImage))
View gist:1883bbadec198ed3f9ea
func checkSpotlightResult() {
print("checkSpotlightResult")
boolCheckSpot = userDefault.boolForKey("spotlightBool")
if boolCheckSpot != nil {
if boolCheckSpot == true {
identifierCheckSpot = userDefault.valueForKey("spotlightIdentifier") as! String
if arrayForCheckSpot.contains(identifierCheckSpot) {
// print("Array title contains \(identifierCheckSpot)")
let index = arrayForCheckSpot.indexOf(identifierCheckSpot)!
let myIndexPath = NSIndexPath(forRow: index, inSection: 0)
You can’t perform that action at this time.