Skip to content

Instantly share code, notes, and snippets.

View AdityaDeshmane's full-sized avatar

Aditya Deshmane AdityaDeshmane

View GitHub Profile
@AdityaDeshmane
AdityaDeshmane / script.php
Created May 16, 2017 11:06
GCM php script
<?php
//To Execute this this from Mac Terminal type php thisFilename.php
$url = 'https://fcm.googleapis.com/fcm/send';
$fields = array (
'to' => 'fq5fI_wcXNY:APA91bGpR-qCYW01wNJ8pnp1ftfgR3DHqPk3ViXDqTYrq-p7MUhry9cPcpXEl7z4GFHGUPcTduww656Rks8cOpSZR-FjrseDX4S-eGdzGaBEqI46KWF8ZJmJpegbf3tzVZwILmnf64aU',//Replace with FIRInstanceID.instanceID().token() this you can get in Appdelegate, note this is NOT token received in didRegisterForRemoteNotificationsWithDeviceToken
'notification' => array (
"body" => "message",
@AdityaDeshmane
AdityaDeshmane / Aggregate Framework
Created October 27, 2016 12:11
Aggregate Framework
# To get this to work with a Xcode 6 Cocoa Touch Framework, create Framework
# Then create a new Aggregate Target. Throw this script into a Build Script Phrase on the Aggregate
######################
# Options
######################
REVEAL_ARCHIVE_IN_FINDER=true
@AdityaDeshmane
AdityaDeshmane / Mac Terminal: Ping with timestamp after every 3 seconds
Last active March 6, 2023 15:43
Mac Terminal: Ping with timestamp after every 3 seconds
//Print on terminal after 3 seconds
ping -i 3 google.com | while read pong; do echo "$(date): $pong"; done
//Pring on terminal after 3 seconds and print log in file
ping -i 3 google.com | while read pong; do echo "$(date): $pong"; done| tee /Users/Aditya/Desktop/TerminalLogs/Saturday_30_July.txt
@AdityaDeshmane
AdityaDeshmane / Enlist all fonts
Last active July 8, 2016 20:22
Blogspot Snippet : iOS Development : Using Custom Fonts
for (NSString* family in [UIFont familyNames])
{
NSLog(@"%@", family);
for (NSString* name in [UIFont fontNamesForFamilyName: family])
{
NSLog(@"Actual font name : %@", name);
}
@AdityaDeshmane
AdityaDeshmane / iOS: Full name search using predicate
Created February 18, 2016 16:13
iOS: Full name search using predicate
-(NSArray*) dataSourceForSearchString:(NSString*) searchedText
{
NSString *strTrimmedSearchText = [searchedText stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSArray *array = [strTrimmedSearchText componentsSeparatedByString:@" "];
NSPredicate *predicate = nil;
/*
@AdityaDeshmane
AdityaDeshmane / iOS: Compare Dates
Created February 18, 2016 15:23
iOS: Compare Dates
- (BOOL) validateDateWithCurrentDate
{
NSDateFormatter *dateFormatter = [NSDateFormatter new];
[dateFormatter setDateFormat:@"MM/dd/yyyy"];
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];//Set timezone to match with [NSDate date] format
_chosenDate = [dateFormatter dateFromString:_labelDateOfBirthSeleced.text];
NSComparisonResult dateComparison = [[NSCalendar currentCalendar] compareDate:[NSDate date]
toDate:_chosenDate
toUnitGranularity:NSCalendarUnitDay];//dont compare time factor
@AdityaDeshmane
AdityaDeshmane / iOS: UITableViewController keyboard handling
Created January 11, 2016 12:58
iOS: UITableViewController keyboard handling
#pragma mark - Keyboard handling
-(void)registerForKeyBoardNotifications
{
// register for keyboard notifications
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWasShown:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillHide:) name:UIKeyboardWillHideNotification object:nil];
@AdityaDeshmane
AdityaDeshmane / iOS: UITableView Row Automatic Height Adjustment (Self Sizing Cell)
Last active January 15, 2016 07:41
iOS: UITableView Row Automatic Height Adjustment (Self Sizing Cell)
Requirement iOS 8 and above
//1. Dyanamic table cells
//Just set following two lines in view did load
_tableView.estimatedRowHeight = someHeightConstant;//provide any value it gets set as default if no constraints are set
_tableView.rowHeight = UITableViewAutomaticDimension;
//2. Static table cells
@AdityaDeshmane
AdityaDeshmane / Mac file split and join commands
Last active December 31, 2015 07:27
Mac file split and join commands
Split:
split -b YOUR_EXPECTED_SIZES YOUR_FILE_NAME PATTERN_NAME_AS_OUTPUT
Join:
cat SPITED_FILES_AS_LIST > NEW_FILE
Example:
Split:
split -b 1024m "XCode_7.2.dmg" "XCode_7.2.dmg."
/* Input Data sample
SWSearchContact *contactModel = [[SWSearchContact alloc] init];
contactModel.arrPhoneNumbers = [arrPhoneNumbers copy];
contactModel.strFirstName = firstName ? firstName : @"";
contactModel.strMiddleName = middleName ? middleName : @"";
contactModel.strLastName = lastName ? lastName : @"";
[_arrMutContacts addObject:contactModel];