Skip to content

Instantly share code, notes, and snippets.

@Denismih
Denismih / TextSize.swift
Created March 11, 2019 12:41 — forked from gnou/TextSize.swift
Calculate height of some text when width is fixed
public struct TextSize {
fileprivate struct CacheEntry: Hashable {
let text: String
let font: UIFont
let width: CGFloat
let insets: UIEdgeInsets
fileprivate var hashValue: Int {
return text.hashValue ^ Int(width) ^ Int(insets.top) ^ Int(insets.left) ^ Int(insets.bottom) ^ Int(insets.right)
@Denismih
Denismih / CoreDataController.swift
Created March 7, 2019 06:22 — forked from kharrison/CoreDataController.swift
Swift wrapper for NSPersistentContainer - Easy Core Data Setup with iOS 10
//
// CoreDataController.swift
//
// Created by Keith Harrison http://useyourloaf.com
// Copyright (c) 2017 Keith Harrison. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright
@Denismih
Denismih / AGAudioRecorder
Created January 31, 2019 14:59 — forked from AshvinGudaliya/AGAudioRecorder.swift
Simple Audio recorder and player in swift 4
//
// AGAudioRecorder.swift
// BaseProject
//
// Created by AshvinGudaliya on 17/09/18.
// Copyright © 2018 AshvinGudaliya. All rights reserved.
//
import UIKit
import AVFoundation
@Denismih
Denismih / AudioRecorder.swift
Created January 31, 2019 14:58 — forked from sssbohdan/AudioRecorder.swift
Audio recorder with simple interface, Swift 4
import Foundation
import AVFoundation
protocol AudioRecorder {
func checkPermission(completion: ((Bool) -> Void)?)
/// if url is nil audio will be stored to default url
func record(to url: URL?)
func stopRecording()
@Denismih
Denismih / AttachmentHandler.swift
Created January 29, 2019 13:42 — forked from deepakraj27/AttachmentHandler.swift
Access Camera, Photo Library, Video and File from User device using Swift 4
//
// AttachmentHandler.swift
// AttachmentHandler
//
// Created by Deepak on 25/01/18.
// Copyright © 2018 Deepak. All rights reserved.
//
import Foundation
import UIKit
@Denismih
Denismih / ImageMessage.swift
Created January 24, 2019 14:43 — forked from rinat-enikeev/ImageMessage.swift
Chatto ImageMessage
// MARK: - ImageMessageModel
import Chatto
import ChattoAdditions
protocol ImageMessageModelProtocol: PhotoMessageModelProtocol {
var url: URL? { get set }
}
public class ImageMessageModel: PhotoMessageModel<MessageModel>, ImageMessageModelProtocol {
@Denismih
Denismih / combining-git-repositories.md
Created January 9, 2019 13:58 — forked from msrose/combining-git-repositories.md
How to combine two git repositories.

Combining two git repositories

Use case: You have repository A with remote location rA, and repository B (which may or may not have remote location rB). You want to do one of two things:

  • preserve all commits of both repositories, but replace everything from A with the contents of B, and use rA as your remote location
  • actually combine the two repositories, as if they are two branches that you want to merge, using rA as the remote location

NB: Check out git subtree/git submodule and this Stack Overflow question before going through the steps below. This gist is just a record of how I solved this problem on my own one day.

Before starting, make sure your local and remote repositories are up-to-date with all changes you need. The following steps use the general idea of changing the remote origin and renaming the local master branch of one of the repos in order to combine the two master branches.