Skip to content

Instantly share code, notes, and snippets.

@Shehryar
Shehryar / Character+ClosedCountableRange.swift
Created December 2, 2019 18:13
Custom operator for creating a closed countable range from two Characters
infix operator ←→
extension Character {
static func ←→(lhs: Character, rhs: Character) -> CountableClosedRange<UInt8> {
guard let lhsInt = lhs.asciiValue, let rhsInt = rhs.asciiValue else {
return 0...0
}
return lhsInt...rhsInt
}
}
@Shehryar
Shehryar / aggregate-framework.sh
Created April 9, 2019 13:45
Fix for creating a fat framework using lipo in Xcode 10.2
#!/bin/sh
if [ -z "$XCODE_VERSION_CORRECT" ]
then
export SUDO_ASKPASS="${PROJECT_DIR}/../scripts/askpass.sh"
fi
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
p print(String(data: try! JSONSerialization.data(withJSONObject: messsages.body, options: .prettyPrinted), encoding: .utf8 )!)
@Shehryar
Shehryar / ExecutionTime.swift
Last active August 13, 2018 17:42
Swift function execution time
import QuartzCore
func executionTimeInterval(block: () -> ()) -> CFTimeInterval {
let start = CACurrentMediaTime()
block();
let end = CACurrentMediaTime()
return end - start
}
export PATH=/usr/local/php5/bin:$PATH
export PHP_COMMAND=/usr/local/php5/bin/php
# Git branch in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
//
// SafariKeychainManager.swift
// UltraMotivator
//
// Created by Shehryar Hussain on 04/15/16.
// Copyright (c) 2014 Shehryar Hussain. All rights reserved.
//
import Foundation
@Shehryar
Shehryar / The Technical Interview Cheat Sheet.md
Created April 5, 2016 14:47 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@Shehryar
Shehryar / stringSubscript.swift
Last active January 27, 2016 19:26
Returns whether a substring exists in a string
extension String {
subscript(pattern: String) -> Bool {
get {
let range = self.rangeOfString(pattern)
return !range.isEmpty
}
}
}
@Shehryar
Shehryar / LoadLocalJSONFromBundle.m
Last active January 19, 2016 18:46
Loads a local JSON file from app bundle
NSError *error = nil;
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"fileName" ofType:@"json"];
NSData = JSONData = [NSData dataWithContentsOfFile:filePath];
NSDictionary *JSONDictionary = [NSJSONSerializatino JSONObjectWithData:JSONData options:kNilOptions error:&error];
@Shehryar
Shehryar / PathPrettyPrint.m
Created February 4, 2015 20:40
Prints out the CGPoint human readable representation of a UIBezierPath to console
- (void)someDrawingMethod
{
// Whatever drawing code
CGMutablePathRef pathRef = CGPathCreateMutable();
// More drawing code
UIBezierPath *path = [UIBezierPath bezierPathWithCGPath:pathRef];
CGpathRelease(pathRef);
CGPathApply(path.CGpath, NULL, outPutCGPath);
}