Skip to content

Instantly share code, notes, and snippets.

View zeeshankhan's full-sized avatar
🏠
Working from home

Zeeshan Khan zeeshankhan

🏠
Working from home
View GitHub Profile
@nielsbot
nielsbot / UIImage+JPEG2000.h
Created February 19, 2012 00:43
Decoding JPEG 2000 files to UIImage
#import <Foundation/Foundation.h>
extern UIImage * UIImageWithJPEG2000Data( NSData * data ) ;
@albertodebortoli
albertodebortoli / UIView+ADBSubviews.h
Created September 21, 2013 20:18
Find the first view of a given class in the iOS7 subviews hierarchy. iOS backward compatible.
//
// UIView+ADBSubviews.h
// iHarmony
//
// Created by Alberto De Bortoli on 06/08/13.
// Copyright (c) 2013 iHarmony. All rights reserved.
//
#import <UIKit/UIKit.h>
@floriankugler
floriankugler / gist:6870499
Last active September 29, 2023 15:56
Mapping of NSURLConnection to NSURLSession delegate methods. Created by Mattt Thompson.
NSURLConnection | NSURLSession
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDelegate connectionShouldUseCredentialStorage: |
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDelegate connection:willSendRequestForAuthenticationChallenge: | NSURLSessionDelegate URLSession:didReceiveChallenge:completionHandler:
| N
@AliSoftware
AliSoftware / struct_vs_inheritance.swift
Last active March 27, 2024 11:57
Swift, Struct & Inheritance: How to balance the will of using Struct & Value Types and the need for Inheritance?
// #!Swift-1.1
import Foundation
// MARK: - (1) classes
// Solution 1:
// - Use classes instead of struct
// Issue: Violate the concept of moving model to the value layer
// http://realm.io/news/andy-matuschak-controlling-complexity/
@rnapier
rnapier / gist:5c80d113895a796fc17b
Last active February 3, 2018 23:20
Wrapping funcs into protocols
/*:
Stuff from [Crustacean](https://developer.apple.com/sample-code/wwdc/2015/?q=protocol).
(Wish I could hide this in a single-file playground somehow.)
*/
import CoreGraphics
protocol Renderer {
func moveTo(position: CGPoint)
func lineTo(position: CGPoint)
func arcAt(center: CGPoint, radius: CGFloat, startAngle: CGFloat, endAngle: CGFloat)
@damianesteban
damianesteban / result.swift
Last active November 13, 2016 19:00
Swift 3 updated code with simple examples from this fantastic article: http://alisoftware.github.io/swift/async/error/2016/02/06/async-errors/
// A Gist.
struct Gist {
let id: String
}
typealias JSONDictionary = [String: AnyObject]
// These methods are "helpers" to transform Data -> JSON -> Result<[Gist]>
func jsonFrom(data: Data) -> Result<AnyObject> {
let json = try! JSONSerialization.jsonObject(with: data, options: [])
import UIKit
import PlaygroundSupport
// https://gist.github.com/erica/6f13f3043a330359c035e7660f3fe7f5
// Original Video: https://www.youtube.com/watch?v=TTmWUSgNOHk
// Video: https://www.youtube.com/watch?v=hmAB3WJOQTU
// Video: https://www.youtube.com/watch?v=DWtavuvmKdw (with zoom and fade)
// String to animate and its attributes
var string = "Hello, playground"
let attributes: [String: Any] = [
@DejanEnspyra
DejanEnspyra / polygon.swift
Created October 3, 2017 19:26
Polygon Google Maps iOS SDK
func polygon(){
// Create a rectangular path
let rect = GMSMutablePath()
rect.add(CLLocationCoordinate2D(latitude: 37.36, longitude: -122.0))
rect.add(CLLocationCoordinate2D(latitude: 37.45, longitude: -122.0))
rect.add(CLLocationCoordinate2D(latitude: 37.45, longitude: -122.2))
rect.add(CLLocationCoordinate2D(latitude: 37.36, longitude: -122.2))
// Create the polygon, and assign it to the map.
let polygon = GMSPolygon(path: rect)
@kharrison
kharrison / RSSFeed.swift
Last active September 1, 2021 01:59
Swift Decodable With Multiple Custom Dates
import Foundation
extension DateFormatter {
static let iso8601Full: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"
formatter.calendar = Calendar(identifier: .iso8601)
formatter.timeZone = TimeZone(secondsFromGMT: 0)
formatter.locale = Locale(identifier: "en_US_POSIX")
return formatter
@shaps80
shaps80 / 1. UserDefaults+Key.swift
Last active September 25, 2020 08:29
Adds a Swift extension to make UserDefaults more consistent to work with.
//
// UserDefaults.swift
//
// Created by Shaps Benkau on 24/05/2018.
// Copyright © 2018 152percent Ltd. All rights reserved.
//
import Foundation
#if os(iOS)