Skip to content

Instantly share code, notes, and snippets.

View AnuragMishra's full-sized avatar

Anurag Mishra AnuragMishra

View GitHub Profile
//: Playground - noun: a place where people can play
import UIKit
import PlaygroundSupport
class LastRowCenteredLayout: UICollectionViewFlowLayout {
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
guard let originalAttributes = super.layoutAttributesForElements(in: rect) else { return nil }
guard originalAttributes.isEmpty == false else { return originalAttributes }
@AnuragMishra
AnuragMishra / DateParsingPerformanceTests.m
Created September 8, 2013 05:45
Date parsing performance comparison
#import <Foundation/Foundation.h>
#include <time.h>
#include <xlocale.h>
#import "sqlite3.h"
#import "ISO8601DateFormatter.h"
#define LOG_DATE 0
static NSUInteger count = 1000000;
@AnuragMishra
AnuragMishra / DateParsingPerformanceComparison.m
Last active July 29, 2020 17:20
Compare the date parsing performance of NSDateFormatter against SQLite's date parser for parsing an iOS 8601 date.
#import <Foundation/Foundation.h>
#import "sqlite3.h"
typedef int64_t timestamp;
NSUInteger randomNumberInRange(NSUInteger start, NSUInteger end);
// Create a sample date using the ISO-8601 format.
// 2013-04-23T16:29:05Z
NSString* generateSampleDate();
@AnuragMishra
AnuragMishra / AppDelegate.m
Created June 29, 2012 01:25
UIWebViewTest
//
// AppDelegate.m
// WebViewBlackPatchTest
//
// Created by Anurag Misra on 6/28/12.
// Copyright (c) 2012 AT&T Interactive. All rights reserved.
//
#import "AppDelegate.h"
@AnuragMishra
AnuragMishra / AppDelegate.m
Created June 29, 2012 00:39
UIWebViewTest
//
// AppDelegate.m
// WebViewBlackPatchTest
//
// Created by Anurag Misra on 6/28/12.
// Copyright (c) 2012 AT&T Interactive. All rights reserved.
//
#import "AppDelegate.h"
@AnuragMishra
AnuragMishra / gist:3014942
Created June 29, 2012 00:32
UIWebView black patch test
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
NSLog(@"Me called");
return NO;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
if Rack::Utils.respond_to?("key_space_limit=")
Rack::Utils.key_space_limit = 262144
end
[{"average_rating":2.5485455989837646,"business_id":1,"created_at":"2012-03-01T23:29:33Z","external_id":"ejjo9o4gv8oo4xuzvrk7ljixn","id":1,"number_of_ratings":61,"title":"Beginning","updated_at":"2012-03-01T23:29:33Z","business":{"address":"3219 Glendale Blvd","city":"Los Angeles","created_at":"2012-03-01T23:29:33Z","id":1,"latitude":34.118106842041016,"longitude":-118.2609634399414,"name":"Canele","phone":"3236667133","state":"CA","updated_at":"2012-03-01T23:29:33Z","ypid":"6655577","zip":"90039"},"menu_item_images":[{"created_at":"2012-03-01T23:32:33Z","id":1,"image_content_type":"image/jpeg","image_file_name":"open-uri20120301-50846-14fskoj","image_file_size":29267,"image_updated_at":"2012-03-01T23:32:33Z","menu_item_id":1,"title":null,"updated_at":"2012-03-01T23:39:27Z"}]},{"average_rating":1.286387324333191,"business_id":1,"created_at":"2012-03-01T23:29:33Z","external_id":"enefkjixjkzgccba7296oz37d","id":2,"number_of_ratings":39,"title":"Chilled Beet Soup","updated_at":"2012-03-01T23:29:33Z","business":{
@AnuragMishra
AnuragMishra / gist:1878318
Created February 21, 2012 19:25
Minification of Array.prototype.slice
​var s = Array.prototype.slice;
s.apply(foo);