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
khanlou / UIImageView+Network.h
Last active Oct 7, 2018
Quick and dirty UIImageView with networking
View UIImageView+Network.h
// UIImage+Network.h
// Fireside
// Created by Soroush Khanlou on 8/25/12.
#import <UIKit/UIKit.h>
khanlou / gist:6091415
Created Jul 26, 2013
Blocks are created on the stack frame that they are on
View gist:6091415
void (^block)();
if (condition) {
block = ^{
NSLog(@"some code");
} else {
block = ^{
NSLog(@"other code");
khanlou /
Created Sep 2, 2013
This is a simple python script for downloading all of the files in your cloud app. Caveats: "bookmarks" can't be downloaded, so they'll be outputted in the log. All files will be downloaded into the same directory as the python script. It requires pycloudapp, which you can find here:
# requires
from import Cloud
import urllib
mycloud = Cloud()
mycloud.auth("username", "password")
khanlou / gist:7156174
Created Oct 25, 2013
Scottish Wizard Voodoo Drink
View gist:7156174
khanlou / SKValueObject.h
Last active Aug 29, 2015
View SKValueObject.h
// SKValueObject.h
// TinyType
// Created by Soroush Khanlou on 5/15/14.
// Copyright (c) 2014 Soroush Khanlou. All rights reserved.
#import <Foundation/Foundation.h>
View NSObject+IfClass.h
#import <Foundation/Foundation.h>
@interface NSObject (IfClass)
- (id)ifClass:(Class)aClass;
View UIColor+LiteralConvertible.swift
import UIKit
extension UIColor: IntegerLiteralConvertible {
class func convertFromIntegerLiteral(value: IntegerLiteralType) -> UIColor {
let r = Double((value >> 16) & 0xFF) / 255;
let g = Double((value >> 8) & 0xFF) / 255;
let b = Double((value) & 0xFF) / 255;
return UIColor(red:r, green:g, blue:b, alpha:1.0)
View MappedArray.m
@interface MappedArray ()
@property (nonatomic) NSArray *backingArray;
@implementation MappedArray
- (instancetype)initWithArray:(NSArray *)array transformationBlock:(id (^)(id object))block {
self = [super init];
View LazyMappedArray.m
@interface MappedArraySentinel : NSObject @end
@implementation MappedArraySentinel @end
@interface LazyMappedArray ()
@property (nonatomic) NSArray *originalArray;
@property (nonatomic) NSMutableArray *backingArray;
@property (nonatomic, copy) id (^block)(id);
khanlou / Swift2.swift
Last active Jun 8, 2019
`any`, `all`, `none`, `first`, and `count` on SequenceType in Swift
View Swift2.swift
import Foundation
extension SequenceType {
func any(@noescape predicate: (Self.Generator.Element) throws -> Bool) rethrows -> Bool {
for element in self {
let result = try predicate(element)
if result {
return true
You can’t perform that action at this time.