Skip to content

Instantly share code, notes, and snippets.

View dayitv89's full-sized avatar
🎢
Rising

Gaurav D. Sharma dayitv89

🎢
Rising
View GitHub Profile
@dayitv89
dayitv89 / Block_Closure_Demo.swift
Last active December 2, 2016 19:37
Closure (Blocks in Objective-C) Demo in swift 3.0.1
public class Custom {
var success: ((Bool) -> String)?
public func testBlock() {
print(success!(true))
}
}
@dayitv89
dayitv89 / upload-to-appstore.sh
Created December 2, 2016 19:39 — forked from jedi4ever/upload-to-appstore.sh
Command upload App/Ipa to the iTunes Connect App Store
#!/bin/bash
set -ex
# This scripts allows you to upload a binary to the iTunes Connect Store and do it for a specific app_id
# Because when you have multiple apps in status for download, xcodebuild upload will complain that multiple apps are in wait status
# Requires application loader to be installed
# See https://developer.apple.com/library/ios/documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide/Chapters/SubmittingTheApp.html
# Itunes Connect username & password
USER=bla
@dayitv89
dayitv89 / shadow.m
Created December 2, 2016 19:40 — forked from NarendraPunchh/shadow.m
Form shadow
- (CGPathRef)renderRect:(UIView*)imgView {
UIBezierPath *path = [UIBezierPath bezierPathWithRect:imgView.bounds];
return path.CGPath;
}
- (CGPathRef)renderTrapezoid:(UIView*)imgView {
CGSize size = imgView.bounds.size;
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(size.width * 0.33f, size.height * 0.66f)];
@dayitv89
dayitv89 / Crop.m
Created December 2, 2016 19:40 — forked from NarendraPunchh/Crop.m
- (void)setMaskImage {
CALayer *mask = [CALayer layer];
mask.contents = (id)[[UIImage imageNamed:@"infoLogo"] CGImage];
mask.frame = self.imgItem.bounds;
self.imgItem.layer.mask = mask;
self.imgItem.layer.masksToBounds = YES;
self.imgItem.contentMode = UIViewContentModeCenter;
}
@dayitv89
dayitv89 / Model+AdditionalParam.h
Created December 2, 2016 19:40 — forked from sandeepsh3090/Model+AdditionalParam.h
Objective-C Object Association for JSON Model
@interface Model (AdditionalParam)
@property (nonatomic, strong) NSString <Optional> * new_key_name;
@end
@dayitv89
dayitv89 / cert2pem
Created December 2, 2016 19:40 — forked from gauravds/cert2pem
From raywenderlich.com
# Convert the .cer file into a .pem file:
$ openssl x509 -in aps_development.cer -inform der -out PushChatCert.pem
# Convert the private key’s .p12 file into a .pem file:
$ openssl pkcs12 -nocerts -in PushChatKey.p12 -out PushChatKey.pem
# Finally, combine the certificate and key into a single .pem file
$ cat PushChatCert.pem PushChatKey.pem > ck.pem
# At this point it’s a good idea to test whether the certificate works.
///
/// Author : Gaurav D. Sharma
/// Run on Swift 3.0
/// IBM swift sandbox : https://swiftlang.ng.bluemix.net/#/repl
///
//// Are you using ObjectMapper for model mapping in swift.
//// Object creation like Mapper<T>().map(jsonString)
//// And you are irritaed with the type name passing and syntex memorization
////
@dayitv89
dayitv89 / String+AES.swift
Created December 2, 2016 19:40 — forked from gauravds/String+AES.swift
String+AES.swift
import Foundation
import CryptoSwift
extension String {
func aesEncrypt(key: String, iv: String) -> String {
let data = self.dataUsingEncoding(NSUTF8StringEncoding)
let enc = AES(key: key, iv: iv, blockMode:.CBC)?.encrypt(data!.arrayOfBytes(), padding: PKCS7())
let encData = NSData(bytes: enc!, length: Int(enc!.count))
let base64String: String = encData.base64EncodedStringWithOptions(NSDataBase64EncodingOptions(rawValue: 0));
@dayitv89
dayitv89 / String+AES.swift
Created December 2, 2016 19:41 — forked from yutelin/String+AES.swift
String+AES.swift
import Foundation
import CryptoSwift
extension String {
func aesEncrypt(key: String, iv: String) throws -> String{
let data = self.dataUsingEncoding(NSUTF8StringEncoding)
let enc = try AES(key: key, iv: iv, blockMode:.CBC).encrypt(data!.arrayOfBytes(), padding: PKCS7())
let encData = NSData(bytes: enc, length: Int(enc.count))
let base64String: String = encData.base64EncodedStringWithOptions(NSDataBase64EncodingOptions(rawValue: 0));
@dayitv89
dayitv89 / MockAPITest.m
Last active October 4, 2017 17:24
Objective-C iOS API Mocking using XCTest (Xcode 8.1) & OHHTTPStub v5.2.3
//
// MockAPITest.m
// iOS-API-Mock-Test
//
// Created by gauravds on 28/12/16.
// Copyright © 2016 iOS Dev Group. All rights reserved.
//
#import "ModelTestHelper.h"