Skip to content

Instantly share code, notes, and snippets.

View muzahid59's full-sized avatar
🎯
Focusing SwiftUI

Muzahidul Islam muzahid59

🎯
Focusing SwiftUI
View GitHub Profile
@muzahid59
muzahid59 / LinkList
Last active July 27, 2020 05:13
Simple Generic Linklist data structure implemented by Swift. Reverse list, apply filter, map are available here.
@muzahid59
muzahid59 / SingleCache
Created February 11, 2019 12:47
Basic idea: * Get value of a give context if exist at current version. * If the value locally not found then fetch from repository and save as current version. * Resolver gives the options which version we want. Old one or new one or both.
struct Version<ContextType, ValueType> {
let context: ContextType
let value: ValueType
}
class SingleCache<ContextType, ValueType> {
typealias CacheVersion = Version<ContextType, ValueType>
typealias CompletionHandler = (_ oldValue: CacheVersion?, _ newValue: CacheVersion?) -> ()
@muzahid59
muzahid59 / README-Template.md
Created May 7, 2018 00:39 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@muzahid59
muzahid59 / gist:fee17ed96f4070172860
Created November 4, 2015 09:33
Helper Variables for Getting Global Queues
var GlobalMainQueue: dispatch_queue_t {
return dispatch_get_main_queue()
}
var GlobalUserInteractiveQueue: dispatch_queue_t {
return dispatch_get_global_queue(Int(QOS_CLASS_USER_INTERACTIVE.value), 0)
}
var GlobalUserInitiatedQueue: dispatch_queue_t {
return dispatch_get_global_queue(Int(QOS_CLASS_USER_INITIATED.value), 0)
@muzahid59
muzahid59 / gist:3e895a187d4064e33446
Last active November 16, 2016 07:00
Objective - C : Property understanding
Nonatomic:
Nonatomic is used for multi threading purposes. If we have set the nonatomic attribute at the time of declaration, then any other thread wanting access to that object can access it and give results in respect to multi-threading.
Copy:
Copy is required when the object is mutable. Use this if you need the value of the object as it is at this moment, and you don't want that value to reflect any changes made by other owners of the object. You will need to release the object when you are finished with it because you are retaining the copy.
Assign:
Assign is somewhat the opposite to copy. When calling the getter of an assign property, it returns a reference to the actual data. Typically you use this attribute when you have a property of primitive type (float, int, BOOL...)
Retain:
@muzahid59
muzahid59 / ValuesForKeys
Created June 21, 2015 05:47
Swift dictionary extension to get the values for multiple keys
extension Dictionary {
func valuesForKeys(keys: [Key])->[Value?]{
var result = [Value?]()
result.reserveCapacity(keys.count)
for key in keys{
result.append(self[key])
}
return result
}
}
@muzahid59
muzahid59 / Asynchronous Download
Last active August 29, 2015 14:22
Swift Download image asynchronously with completion handler
dowloadImage("link", completion: {(var image) in
if image {
// downloaded successfully
}
})
// dowload image with completion handler
func dowloadImage(link: String, completion:(image: UIImage) -> Void){
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {
@muzahid59
muzahid59 / AccordionTableView.swift
Created May 26, 2015 09:19
Swift collaspable or expandable tableview
//
// AccordionTableView.swift
// PracticePro
//
// Created by Muzahidul Islam on 5/26/15.
//
import UIKit
@muzahid59
muzahid59 / Determine shooting direction
Last active August 29, 2015 14:21
Swift: Shoot Sprite at the specific direction
func + (left: CGPoint, right: CGPoint) -> CGPoint {
return CGPoint(x: left.x + right.x, y: left.y + right.y)
}
func - (left: CGPoint, right: CGPoint) -> CGPoint {
return CGPoint(x: left.x - right.x, y: left.y - right.y)
}
func * (point: CGPoint, scalar: CGFloat) -> CGPoint {
return CGPoint(x: point.x * scalar, y: point.y * scalar)