Thursday, June 13, 2024

"Best speech ever": Roger Federer's address to graduates

Roger Federer offered three pieces….well four pieces…of advice in his Commencement address at Dartmouth

1: Effortless is a myth.

People often mean it as a compliment but “the truth is,” he said, “I had to work very hard to make it look easy.”

We should be proudest of the victories we earn when the competition is fierce.

“Because they prove that you can win not just when you are at your best, but especially when you aren’t. Most of the time it’s not about having a gift. It’s about having grit.”

2: It’s only a point—perfection is impossible.

“When you’re playing a point, it is the most important thing in the world. But when it’s behind you, it’s behind you. This mindset is really crucial, because it frees you to fully commit to the next point and the next one after that with intensity, clarity, and focus.”

He shared that a sign of becoming a champion “is overcoming hard moments.”

“The best in the world are not the best because they win every point. It’s because they know they’ll lose again and again, and have learned how to deal with it.”

3: Life is bigger than the court.

He underscored the importance of embracing the fullness of life and finding fulfillment in many ways.

“As a student at Dartmouth, you picked a major and went deep. But you also went wide. Engineers learned art history, athletes even sang a cappella, and computer scientists learned to speak German.”

And that “leaving a familiar world behind and finding new ones is incredibly, deeply, wonderfully exciting.”

4, His last lesson: For our forehand, we should use an Eastern grip while keeping our knuckles slightly apart without squeezing the grip too hard. And remember, it starts with footwork and the take-back is as important as the follow-through.

“It’s just good technique,” he said.

His full speech to our Class of 2024: 

https://www.youtube.com/watch?v=pqWUuYTcG-o

https://home.dartmouth.edu/news/2024/06/2024-commencement-address-roger-federer

 

Wednesday, April 26, 2023

Command to check if particular server URL supports forward secrecy

 These ciphers are employed if Forward Secrecy is supported by server

 openssl s_client -connect server.com:443 -cipher "ECDHE, EECDH"

 openssl s_client -connect server.com:443 -cipher "DHE, EDH"

If the command results in a “sslv3 alert handshake failure” error, the Forward Secrecy property is not supported by the server. 

Command to check ATS configuration of URL in mac

 The below terminal command helps us get detailed ATS check on specific URL

nscurl --ats-diagnostics <URL>

Wednesday, March 22, 2023

How to configure PHP and Apache with Mac OS Monterey and above

 PHP has been removed since Monterey 

So we're going to install latest PHP using Home brew and edit the configuration files of apache web server so PHP web hosting is supported from local machine.

 - If you don't have Homebrew installed , use the below terminal command to set up home brew

     /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

 - Once the brew set up is success , feed the below command in terminal to instal latest PHP 

    brew install php

- start php using below command

   brew services start php

 - create sites directory under current user root directory using below command

     sudo mkdir ~/Sites

- open apache folder and create username.conf using below terminal command

     cd /etc/apache2/users
     sudo nano username.conf

- Feed the below text into the file and press Ctrl+o to save
    
    <Directory "/Users/username/Sites/">
      AllowOverride All
      Options Indexes MultiViews FollowSymLinks 
      Require all granted
    </Directory>

 - Now let's open httpd.conf using the below command
     
     sudo nano /etc/apache2/httpd.conf

- Uncomment the below lines from the above file

   LoadModule authz_core_module libexec/apache2/mod_authz_core.so
   LoadModule authz_host_module libexec/apache2/mod_authz_host.so
   LoadModule userdir_module libexec/apache2/mod_userdir.so
   LoadModule include_module libexec/apache2/mod_include.so
   LoadModule rewrite_module libexec/apache2/mod_rewrite.so

- Add the following lines into the same above file
   
  LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so

  <FilesMatch \.php$>
  SetHandler application/x-httpd-php
  </FilesMatch>

- Uncomment the below line 

  Include /private/etc/apache2/extra/httpd-userdir.conf

- Search for AllowOverride None in the file and replace with below text

    AllowOverride All

- Save the file by pressing Ctrl+o

- Open one more apache file using below command

    sudo nano /etc/apache2/extra/httpd-userdir.conf

- Uncomment the below line and save it
  
    Include /private/etc/apache2/users/*.conf

- Restart the apache using below command

   sudo /usr/sbin/apachectl restart

- Check if webserver is running by opening the below url in browser

   http://localhost

- To check if PHP is supported , let's create a php file in webserver directory and try acessing it in the browser

   sudo touch /Library/WebServer/Documents/index.php
   sudo nano /Library/WebServer/Documents/index.php

and enter the below text and save it.

   <?php 
    phpinfo(); 
  ?>

- Check if PHP is supported by opening below url in browser
 
   http://localhost/index.php
 
- If PHP is not signed yet , then you might get an error. Find the exact error message using below command in terminal

 apachectl -t -D DUMP_VHOSTS 

- If you find code signing issue in the above response, then Create a CA for code signing and do code signing

- Now feed below command to sign the php using terminal 

      codesign --sign "your-authority-name" --force --keychain ~/Library/Keychains/login.keychain-db /opt/homebrew/opt/php/lib/httpd/modules/libphp.so

- Open the httpd.conf again and change the uncommented php line with below text

     LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so "your-authority-name"

- Restart the apache again with below command

    sudo /usr/sbin/apachectl restart

- Access the PHP file again through browser, you should be able to see a proper php web page now



Thursday, February 4, 2021

Reclaim your memory from mac SSD without using any third party software

I took following steps and saved over 100GB


1. Opened Devices & simulators from Xcode and removed all the unwanted simulators

2. Cleared all the unwanted simulator runtimes from the below path

    /Library/Developer/CoreSimulator/Profiles/Runtimes

3. Removed all the simulator logs from the below path

     ~/Library/Logs/CoreSimulator/

4. Removed the unwanted device support and all the device logs,derived data and user data from below path

    ~/Library/Developer/Xcode/iOS DeviceSupport

    ~/Library/Developer/Xcode/iOS Device logs

    ~/Library/Developer/Xcode/DerivedData

    ~/Library/Developer/Xcode/UserData

5. Remove the temporary files and caches from the below path

     /private/var/folders/

6. Remove the system caches from the below path

    ~/Library/Caches

FYI:

It's always good to take a back up in time machine before doing , just in case if something goes wrong.

Saturday, January 30, 2021

How to join and study a university in UK

 Documents needed

  1. Get a transcript of your marksheet
  2. Get SOP ( Statement of purpose )
  3.  Get LOR ( Letter of recommendation ) from your Indian university if applicable employer
  4. Get IELTS score


Process:

  • Look for good colleges (https://russellgroup.ac.uk/about/our-universities/) and apply with the above documents and you would get a response in weeks. 
  • If it's a positive response, they'd offer conditional offer letter 
  • With that they would ask list of other documents and initial tuition fee like 2000 pound. 
  • Once you have successfully uploaded the documents and paid the initial fees they would  offer unconditional offer letter
  • With this letter you have become student of the university and you may start the visa process.
  • For visa process you can go to VFS and this will redirect to UKVisa site.
  • You will have to pay for NHS and health insurance which will be like 40k INR I heard recently it has changed to 80k INR
  • You will have to pay visa fee which would be 30k INR.
  • Then you will get visa appointment and you will have to carry all the originals for verification and they will take biometrics and issue the visa.
  • Before that you will have to show your account with 2Million INR for financial security. 
  • If you have applied for Education loan then you will have to show loan sanction letter
  • With visa one can book flight and travel to UK and you will have to collect BRP from post office within 1 or 2 weeks.

P.S

  1. In case of education loan , you may use conditional offer letter and start applying for loan with that. 
  2. If you have decided to drop off for some reason , they you may ask for initial tuition fee refund and most universities do the refund.
  3. Always choose a college which is close to a city that offers more part time jobs.


Thursday, November 5, 2020

Unified logging in iOS

 One of most important use of unified logging is that it facilitates us to see the logs from extensions.

Using apple xcode doesn't show the logs in it from extension.

All we have to do is use the following import

    import os.log

If you want to log something use the below statement

  os_log("")

Now you can see all this logs printed in terminal. 


P.S:

It can be very useful while you are working with extensions. Because we have to attach the extension with xcode for us to actovate the breakpoint inside  extension. Till we attach lot of things can happen we may want to know that's when the unified logging comes to our rescue. 

 

Sunday, November 24, 2019

Uprading to SSD from HDD on mac book pro

Recently my mac book pro has become very slow and found out that my HDD(Hard Disk Drive) has become faulty and that's the reason it's very slow.

I went to apple store to fix it and it was little expensive over there like £230 and they can do only as is replacement for HDD with another HDD and they won't do HDD to SSD(Solid State Drive)

So I went over to third party apple repair shop and they were ready to upgrade my mac book pro with SSD but again it was little expensive like £280.   

So I decided , I would do it myself and fixed it successfully so I thought I would share what I did to do this so that it's helpful for anyone who's looking to do.

1.  Buy the right SSD for your machine. I recommend Cruical.com. Visit this site and it'll ask you to download an app and it'll tell you what are the SSD you can buy for your machine.

2. Buy a Laptop or computer repairing screw driver set. 

3. Remove the screws from lower case.

4. Remove the battery connection cable from the motherboard

5. Remove the battery using pull tab

6. Disconnect the HDD connecting cable

7. Take out the HDD and remove the retaining screws from the side of HDD

8. Attach the retaining screws to SSD 

9. Put the SSD in place of HDD

10.Attach the connecting cable on SSD then attach the battery cable with mother board

11.Put all the screws back

12. Start up your mac and press command + option + R 

13. This will bring internet recovery 

14. After recovery choose disk utility and erase the newly bought SSD with Format: APFS and Partition type: GUID

15. After erasing , choose internet recovery or restore time machine back up

Then follow the normal steps like entering the apple id to sign in once the recovery is over. That's all

Monday, June 25, 2018

how do regular users can install iOS 12 development beta

Public betas for regular users follow the developer betas.

if you are a regular user and want to join the beta test , head to beta.apple.com on the device you want to run the beta on.

you can enrol there, and download a  specific profile that will allow your device to download the beta releases 

after that , new beta releases will be delivered just a regular iOS updates are: You will get a notification when one is ready and can check manually by going to Settings -> General -> Software Update

Monday, May 7, 2018

how to restrict mobile app access to only wifi

In enterprise application , the need for apps to use only wifi comes to picture sometimes as they can access intranet through wifi.

But with the advent of wifi-assist.It's possible sometimes Mobile data will be used for internet connectivity simultaneously along with wifi.

so how to stop this from happening so that app can use only wifi not mobile data.

allowscellularaccess property of NSMutableURLRequest solves the issue.

so if set this value to NO then if there is no wifi then it'll ignore the mobile data and return internet connect offline error message

Here is sample code to test

    NSMutableURLRequest *request=[[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:@"https://www.google.com"]];    [request setAllowsCellularAccess:NO];    NSError *error;
        NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];    NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil];        [request setHTTPMethod:@"GET"];
        NSURLSessionDataTask *postDataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        NSLog(@"error:%@",error);
        NSLog(@"success:%@",response);
    }];
        [postDataTask resume];

Here is the sample error message we get


Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={NSUnderlyingError=0x1c004b700 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}}, NSErrorFailingURLStringKey=https://www.google.com/, NSErrorFailingURLKey=https://www.google.com/, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=50, NSLocalizedDescription=The Internet connection appears to be offline.}

Thursday, March 8, 2018

Multipath tcp in iOS

Multipath TCP enables iOS to use both wifi and data connection simultaneously which increases the user experience and works around common problem network latency,network connection drop out,etc.

It was introduced in iOS 7 itself and it was used by only Siri but it is released for developers.
since iOS 11.

This can be lot more useful when it comes to streaming of audio and video.

One can opt multipath tcp in NSURLSession

var multipathserviceType:URLSessionConfiguration.MultipathServiceType
none =0
handover = 1
interactive=2

None:

It never used multipath acts as usual

Handover:

acts more like how wifi assit works i.e only when wifi is weak it uses data and if wifi signal gets stronger then it uses wifi

Interactive:

It uses both wifi and data at a same time but it will not be very aggressive on data network.
Siri uses interactive mode

Aggregate:

Same as interactive but it'll use data network aggressively

Wednesday, January 31, 2018

Easy to use java decompiler

Recently I had to get java class files out of JAR that was provided to me.

I could get easily class files from JAR by renaming the file from myLib.jar to myLib.zip.

But I couldn't find a easy way to decompile .class file (byte code ) back to java.

I found some online services to do that but its not safe and most of them are blocked due to firewall in corporate network.

and doing this manually with javap which is part of JDK is not good as it displays other information than original source code which makes kind of hard to copy and save as java file.

so I thought like I would use a stand alone desktop program.

I found JD GUI good

because it provides good UI(Tree view explorer) for us to see and shows the actuall source code and easy to export as java file

I tried couple of other Stand along programs but it wouldn't support latest mac.


Thursday, January 25, 2018

Ever wanted to run your windows apps on Android device, now its possible with Wine 3.0

With the introduction of Wine 3.0 now you can run windows 7 apps on Android.

It works better with X86 based processor and with ARM based phone you are limited to programs that runs with Windows RT.

One more thing is it even allows you to run some windows application on mac.

Even though this application is not bugfree,Its still worth a try.



Thursday, November 30, 2017

How to make ipa using terminal

Here to script to do that.
xcodebuild -exportArchive -archivePath myproject.xcarchive -exportPath IPA -exportOptionsPlist options.plist
Here is sample options.plist


Monday, November 20, 2017

Date and time issues with Mobile app and API

Most of the times while we develop mobile apps ,we run into date and time issues with respect to timezones and summer time.

so easy solution is to make sure API supports ISO-8601 date and time format  and its already a internet standard.

so basically when we submit the date and time we can submit the date and time in ISO-8601 date and time format.API developers will be storing it as UTC in DB and they will be returning the date and time format in UTC format.



Monday, September 11, 2017

Where do I find Objective class declarations for Swift ?

This is a common question for lots of people.

The swift files are made available to Objective C world with [SwiftName]-swift.h so anybody can go in there and c their objective declaration for their swift counterparts.

so to use this will simply import the header files in objective c class

likewise in-order to consume objective c objects in swift world we'll just mention those things in bridging header thats all and its immediately available to swift world.

so I wondered where the objective files are stored in swift syntax so that it can be used in swift world.

these files can be found when you make following selection in xcode

                                    Navigate -> Jump to generated files


Thursday, May 11, 2017

Its possible to develop iOS apps in Windows now

Microsoft has released Xamarin Live Player using which one can debug and develop iOS apps just with windows machine
Here is the official link for that
https://www.xamarin.com/live

P.S:
To sign and release the app Apple system is required anyhow

Thursday, April 27, 2017

Ever wanted to download older apple developer tools

You can find tools like Xcode 3 with iOS 4 SDK

https://developer.apple.com/download/more/

FYI:
Don't risk yourself to download these tools from unofficial sources
Which can lead to XcodeGhost problems too

Tuesday, April 25, 2017

Simulator builds for iOS

Go to ~/Library/Developer/CoreSimulator/Devices/

You will find directories with alphanumeric names

then click on the one of the directories and make following selection

Data/Containers/Bundle/Application/

Again you will find directories with alphanumeric names if you click on that you will find

Simulator build over there

You can copy this .app over and and install it using following command on a running simulator

xcrun simctl install booted *.app

Note:

Installing iOS device build on simulator will not work out.

  • iPhone simulator uses i386 architecture
  • iPad simulator builds uses x86_34 architecture
  • iOS device build uses ARM based architecture

iOS simulator has so many drawbacks

Simulator uses lower level OSx frameworks not actual iOS frameworks so results can be different sometimes
GPU based UI rendering is different etc..

iOS simulator is good for functional testing and general and UI based alignment verifications

Wednesday, February 22, 2017

Git merging the conflicts through command line

To merge the conflict I had to do the following steps

1.Swithcing to the mother branch

 git checkout mother_branch_name

mother_branch -> to which I have to merge my child branch

2.Merging the child branch to mother branch

 git merge child_branch_name

Now it'll notify the conflicting files

3.Opening the merge tool

 git mergetool --tool=emerge

There are 17 different merge tools out of that I prefer emerge as its easy

Here are some of the keys to operate emerge tool

N- next
P- previous
A- choose the mother branch change
B- choose the child branch change
Q - Quit and save the changes

As soon as the screen appears ,Press N to see the conflict .. then use P and N to navigate across the conflicts

choose A and B on each conflict

Once you are done press Q to save or discard the modifications you did

To know more about the emerge tool.click here