Posts

Setting up Graphql Server

This tutorial is based on https://www.apollographql.com/docs/apollo-server/getting-started/  Install node and npm. If you don't have them installed do the following 1 and 2:     1. Install homebrew from  https://brew.sh/     2. Install node and npm using homebrew Create a new folder named graphql-server-example cd into it. setup node project using the command: npm init --yes This creates a package.json file. Install apollo-server and graphql   using: npm install apollo-server graphql Create an empty index.js file with command touch index.js Add the following content to the file: const { ApolloServer , gql } = require ( 'apollo-server' ); // A schema is a collection of type definitions (hence "typeDefs") // that together define the "shape" of queries that are executed against // your data. const typeDefs = gql ` # Comments in GraphQL strings (such as this one) start with the hash (#) symbol. # This "Book" type defines the queryable field

Asynchronous programming in Android

 Asynchronous programming in Android can be done in various ways. Two of them are: 1. Using callback 2. Using coroutines Below is the example of using callback: Below is the example of using coroutine: ... Note that suspend function can only be called either from a  coroutine or from another suspend function. Here GlobalScope implements CoroutineScope and launch is a coroutine builder which is an extension function of CoroutineScope. Coroutine A  coroutine  is an instance of suspendable computation. It is conceptually similar to a thread, in the sense that it takes a block of code to run that works concurrently with the rest of the code. However, a coroutine is not bound to any particular thread. It may suspend its execution in one thread and resume in another one. Coroutines can be thought of as light-weight threads // Sequentially executes doWorld followed by "Hello" fun main() = runBlocking {     doWorld()     println("Done") } // Concurrently executes

Android Studio Disable Ktlint import ordering

 Create a file named .editorconfig any where in the project with the following content. [* . { kt , kts }] disabled_rules = import-ordering This should waive the requirement for the imports to be ordered lexicographically.

git status is not showing changed files.

 If git add isn't adding updated/changed files or git isn't tracking a changed file, then run the following command: git add -f path/to/the/file

Change Density of Android Emulator in Mac OS

 Open the following file: /Users/yourUserName/.android/avd/< CustomDevice_API_19 >.avd/config.ini CustomDevice_API_19 is the name of your emulator. Change the  hw.lcd.density =160 or any other values required. The possible values for lcd density are: 120, 160, 213, 240, 280, 320, 360, 400, 420, 480, 560, 640

Android Color Hex Value Opacity Chart

  How to set transparency with hex value? For example, you want to set  40%  alpha transparence to  #000000  (black color), you need to add  66  like this  #66000000 . 100% — FF 99% — FC 98% — FA 97% — F7 96% — F5 95% — F2 94% — F0 93% — ED 92% — EB 91% — E8 90% — E6 89% — E3 88% — E0 87% — DE 86% — DB 85% — D9 84% — D6 83% — D4 82% — D1 81% — CF 80% — CC 79% — C9 78% — C7 77% — C4 76% — C2 75% — BF 74% — BD 73% — BA 72% — B8 71% — B5 70% — B3 69% — B0 68% — AD 67% — AB 66% — A8 65% — A6 64% — A3 63% — A1 62% — 9E 61% — 9C 60% — 99 59% — 96 58% — 94 57% — 91 56% — 8F 55% — 8C 54% — 8A 53% — 87 52% — 85 51% — 82 50% — 80 49% — 7D 48% — 7A 47% — 78 46% — 75 45% — 73 44% — 70 43% — 6E 42% — 6B 41% — 69 40% — 66 39% — 63 38% — 61 37% — 5E 36% — 5C 35% — 59 34% — 57 33% — 54 32% — 52 31% — 4F 30% — 4D 29% — 4A 28% — 47 27% — 45 26% — 42 25% — 40 24% — 3D 23% — 3B 22% — 38 21% — 36 20% — 33 19% — 30 18% — 2E 17% — 2B 16% — 29 15% — 26 14% — 24 13% — 21 12% — 1F 11% — 1C 10% — 1A 9% — 17 8% —

Hide the keyboard from emulator

Image