Posts

Difference between dependencies and dev-dependencies?

In your node project in the file package.json , you may have seen two similar JSON element: “dependencies”: {             … }  and “ devDependencies” : {             … } devDependencies contains modules which are only required during development. To save a module as devDependencies on installation, we do: npm install <module-name> --save-dev or shortcut: npm i <module-name> -D Some examples of dev dependencies are Jest, Chai, Nodemon, Babel, etc. dependencies contains modules that are required at runtime. To save a module as run time dependencies , we do: npm install <module-name> --save or shortcut: npm i  <module-name>  -S Some examples of runtime dependencies are Express, React, Apollo-client etc.

Allow Installation of Application from Unknown Source in Mac

If Mac is not allowing you to install/run application from unknown source, go to command line and run the following command: sudo spctl --master-disable Now install or run the application that was previously blocked. It should work fine. If you don't care about security then you can close the terminal and continue to work. But if you do, go to step Step 2. Optional Step 1: Now if you go to System Preference -> Security and Privacy you will see that Install From Anywhere is enabled. Optional Step 2: Go to command line and run the following command: sudo spctl --master-enable

Download or Generate GraphQL Schema

Image
If you are using Apollo server on localhost and want to generate or retrieve the schema ( I did this because I needed the schema.json file in my Android project), do the following: Install Apollo CLI using: npm install -g apollo After this is installed, run the following command: apollo client:download-schema --endpoint=http://localhost:8080 This will download the schema.json file in the present working directory.  If the endpoint of your server is not localhost, change it to the respective URL. You may need sudo permission while installing apollo.

Decreasing the size of Vector Drawables in Android

Follow the steps written in this github page: https://github.com/alexjlockwood/avocado Run the following command: sudo npm install -g avocado If vector_old.xml is the old vector drawable file, runt he following command: avocado vector.xml The vector.xml file will be modified into small size file by replacing it.

Install and Uninstall Android app from ADB

To Install: To install the apk from command line(after it is built successfully), adb install -t app.apk Don't forget to give the full path to the apk. To Uninstall: In short, to uninstall apk from command line type: adb uninstall package_name To be more precise: Find the exact package name by typing: adb shell su 0 pm list packages From the list, find the name of the package of your app (Say it is com.sulav.app.us.debug ) Now type: adb uninstall com.sulav.app.us.debug The app is now uninstalled from the emulator You can also find the package name by: Go to Device File Explorer in Android Studio -> data -> data -> Now scroll till you find the name of the package.

Sending Broadcast from ADB to Emulator

If you are testing an app and want to send a broadcast of an Intent from ADB, read through. To enable root access, use an emulator image like Google APIs Intel x86 Atom System Image not Google Play Intel x86 Atom System Image To test it, run  adb root . It should say restarting adbd as root or adbd is already running as root not adbd cannot run as root in production builds  Now either from a terminal app or from Terminal tab in Android Studio, type the following: adb shell su am broadcast -a android.intent.action.BOOT_COMPLETED You should get the following output: Broadcasting: Intent { act=android.intent.action.BOOT_COMPLETED } Broadcast completed: result=0

Retrofit 2 : REST Client for Android

Image
Using RxJava with Retrofit Add the following dependencies in Module level  build.gradle file: dependencies { /// ... // Add Retrofit implementation 'com.squareup.retrofit2:retrofit:2.5.0' // Using gson as converter implementation 'com.squareup.retrofit2:converter-gson:2.5.0' // A Converter which supports converting strings and both primitives and their boxed types to text/plain bodies. implementation 'com.squareup.retrofit2:converter-scalars:2.5.0' implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' // Because RxAndroid releases are few and far between, it is recommended you also // explicitly depend on RxJava's latest version for bug fixes and new features. // (see https://github.com/ReactiveX/RxJava/releases for latest 2.x.x version) implementation 'io.reactivex.rxjava2:rxjava:2.2.8' implementation 'com.squareup.retrofit2:adapter-rxjava2:2.5.0' implement