Skip to content

Instantly share code, notes, and snippets.

View irshadpc's full-sized avatar
🎯
Focusing

IRSHAD PC irshadpc

🎯
Focusing
  • Hatio Innovations Private Limited
  • Kochi, India
  • X @_irshadpc
View GitHub Profile
@irshadpc
irshadpc / iOSMapKitFitAnnotations.m
Last active October 16, 2016 14:39 — forked from andrewgleave/iOSMapKitFitAnnotations.m
Zooms out a MKMapView to enclose all its annotations (inc. current location)
MKMapRect zoomRect = MKMapRectNull;
for (id <MKAnnotation> annotation in mapView.annotations) {
MKMapPoint annotationPoint = MKMapPointForCoordinate(annotation.coordinate);
MKMapRect pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0, 0);
if (MKMapRectIsNull(zoomRect)) {
zoomRect = pointRect;
} else {
zoomRect = MKMapRectUnion(zoomRect, pointRect);
}
}
@irshadpc
irshadpc / gist:f43e7cb2010fe5f4a7c84fd89bb57da4
Created October 22, 2016 15:42 — forked from adamgit/gist:3705459
Automatically create cross-platform (simulator + device) static libraries for Objective C / iPhone / iPad
##########################################
#
# c.f. http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4
#
# Version 2.82
#
# Latest Change:
# - MORE tweaks to get the iOS 10+ and 9- working
# - Support iOS 10+
# - Corrected typo for iOS 1-10+ (thanks @stuikomma)
@irshadpc
irshadpc / UIImagePickerController+cats.m
Created November 3, 2016 07:13 — forked from iandundas/UIImagePickerController+cats.m
How to detect iOS Photo library or Camera permissions (>iOS8)
//
// Created by Ian Dundas on 16/03/15.
//
#import "UIImagePickerController+cats.h"
#import <AVFoundation/AVFoundation.h>
#import "Photos/Photos.h"
/*
example usage:
@irshadpc
irshadpc / gist:4c3b1677996a024eb23ee0bc85667536
Created February 23, 2017 06:17
Stripping Unwanted Architectures From Dynamic Libraries In Xcode
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
@irshadpc
irshadpc / CalculatorView.swift
Created February 28, 2017 11:45 — forked from natecook1000/CalculatorView.swift
An IBInspectable Calculator Construction Set
// CalculatorView.swift
// as seen in http://nshipster.com/ibinspectable-ibdesignable/
//
// (c) 2015 Nate Cook, licensed under the MIT license
/// The alignment for drawing an String inside a bounding rectangle.
enum NCStringAlignment {
case LeftTop
case CenterTop
case RightTop
#!/bin/sh
# build.sh
#
# Created by IRSHAD PC on 10/02/17.
# Copyright © 2017 IRSHAD PC. All rights reserved.
PROJDIR=${WORKSPACE}/___PROJECT NAME___
PROJECT_NAME=___XCODE PROJECT NAME___
TARGET_SDK="iphonesimulator4.0"

Objective-C Coding Convention and Best Practices

Most of these guidelines are to match Apple's documentation and community-accepted best practices. Some are derived some personal preference. This document aims to set a standard way of doing things so everyone can do things the same way. If there is something you are not particularly fond of, it is encouraged to do it anyway to be consistent with everyone else.

This document is mainly targeted toward iOS development, but definitely applies to Mac as well.

Operators

NSString *foo = @"bar";
@irshadpc
irshadpc / Jaibroken.m
Created May 31, 2017 08:00
Jaibroken test
+(BOOL)isJailbroken{
#if !(TARGET_IPHONE_SIMULATOR)
if ([[NSFileManager defaultManager] fileExistsAtPath:@"/Applications/Cydia.app"]){
return YES;
}else if([[NSFileManager defaultManager] fileExistsAtPath:@"/Library/MobileSubstrate/MobileSubstrate.dylib"]){
return YES;
}else if([[NSFileManager defaultManager] fileExistsAtPath:@"/bin/bash"]){
return YES;
@irshadpc
irshadpc / SqlInjection.m
Created May 31, 2017 08:04
Sql Injection Vulnerable sample
NSString *uuid = [myConnection getUUID];
NSString *statement = [NSString StringWithFormat:@"SELECT username FROM users
where uuid = '%@'",uuid];
const char *sql = [statement UTF8String];
@irshadpc
irshadpc / SqlinjectionValid.m
Created May 31, 2017 08:06
Sql injection Valid Snippet
const char *sql = "SELECT username FROM users where uuid = ?";
sqlite3_prepare_v2(db, sql, -1, &selectUuid, NULL);
sqlite3_bind_int(selectUuid, 1, uid);
int status = sqlite3_step(selectUuid);