Skip to content

Instantly share code, notes, and snippets.

Soroush Khanlou khanlou

Block or report user

Report or block khanlou

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ProbingDictionary.swift
import Foundation
struct ProbingDictionary<Key: Hashable, Value> {
enum Item: CustomStringConvertible {
case element(Key, Value)
case empty
case tombstone
var isEmpty: Bool {
if case .empty = self {
View ObjectStorage.swift
//
// ObjectStorage.swift
// Soroush Khanlou
//
// Created by Soroush Khanlou on 3/8/19.
// Copyright © 2019 Soroush Khanlou. All rights reserved.
//
import Foundation
@khanlou
khanlou / URLRequest.swift
Last active Feb 9, 2019 — forked from peterprokop/URLRequest.swift
Print NSURLRequest in cURL format
View URLRequest.swift
//
// URLRequest.swift
//
// Created by Peter Prokop on 17/08/2017.
// Modified by Soroush Khanlou on 09/12/2018.
import Foundation
public extension URLRequest {
View LazyUniquedSequence.swift
struct LazyUniquedSequence<Element>: Sequence {
let base: AnySequence<Element>
let isEqual: (Element, Element) -> Bool
init<S: Sequence>(_ sequence: S, isEqual: @escaping (Element, Element) -> Bool) where S.Element == Element {
self.base = AnySequence(sequence)
self.isEqual = isEqual
}
@khanlou
khanlou / SKSerialInputStream.h
Last active Dec 4, 2018
Partially adapted from AFMultipartBodyStream
View SKSerialInputStream.h
//
// SKSerialInputStream.h
// inputstream
//
// Created by Soroush Khanlou on 11/4/18.
// Copyright © 2018 Soroush Khanlou. All rights reserved.
//
#import <Foundation/Foundation.h>
View LazyUniquedCollection.swift
struct LazyUniquedSequence<Element>: Sequence {
let base: AnySequence<Element>
let isEqual: (Element, Element) -> Bool
init<S: Sequence>(_ sequence: S, isEqual: @escaping (Element, Element) -> Bool) where S.Element == Element {
self.base = AnySequence(sequence)
self.isEqual = isEqual
}
View HTTPMethod.h
@interface HTTPMethod: NSString
+ (HTTPMethod *)GET;
+ (HTTPMethod *)POST;
@end
@khanlou
khanlou / ImageFetcher.kt
Created Jul 8, 2018
Simple image fetching and caching example. Intended for Firebase but the fetching architecture could be abstracted out. Dependent on `com.jakewharton.disklrucache.DiskLruCache`.
View ImageFetcher.kt
package amal.global.amal
import android.content.Context
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.util.LruCache
import com.google.firebase.storage.StorageReference
import com.jakewharton.disklrucache.DiskLruCache
import java.io.File
import java.security.MessageDigest
View PassThroughView.swift
import UIKit
class PassThroughView: UIView {
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
let result = super.hitTest(point, with: event)
if result == self { return nil }
return result
}
View ReversibleRange.swift
public struct ReversibleRange<Bound>: Equatable where Bound: Comparable {
public let startingBound: Bound
public let endingBound: Bound
public init(startingBound: Bound, endingBound: Bound) {
self.startingBound = startingBound
self.endingBound = endingBound
}
public var isReversed: Bool {
You can’t perform that action at this time.