Posts

Clear terminal with a shortcut

Hey welcome to my blog. There is a simple command to clear out the terminal.  Just hit this shortcut: CMD + k

Monitor mac from terminal | htop command in MAC

Usage: To analyse CPT usage, memory usage, taks running. htop command in Linux system is a command line utility that allows the user to interactively monitor the system’s vital resources or server’s processes in real time. htop is a newer program compared to top command, and it offers many improvements over top command. htop supports mouse operation, uses color in its output and gives visual indications about processor, memory and swap usage. htop also prints full command lines for processes and allows one to scroll both vertically and horizontally for processes and command lines respectively. Syntax: htop [-dChusv] Understand the columns: PID: ProcessId UserId: User through which process is running Priority: 0 to 40 NI: The nice value of the process, which affects its priority. (-19highest to 19lowest) VIRT: virtual memory being used by the process RES: How much physical RAM the process is using, measured in kilobytes. SHR: How much shared memory the process is using. S: The curre...

Learning Graphql | A query language for your API | Part1

What is Graphql GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools. Rest is used to created the APIs, while Graphql sits in front of the API. Graphql can sit in front of an existing API as well.  You can still have a API underneath Graphql. Graphql is just a spec, what it can, it should, would do. Facebook created GraphQL-JS, which is an JS implementation of graphql spec in JS. It gives power to client, to request the data that they want. Not more, not less.  It's strongly types, like typescript.  Graphql is kind of SQL for your API. Since it's just a query language.  Rest vs graphql Rest is an interface for building api, graphql is a query language. They do similar things but d...

Don't let your MAC sleep | Cool terminal commands Part2

 Hey, have you ever faced an issue where you don't want your MAC to enter into sleep mode. Here is the solution. Open the terminal by typing 'terminal' in the spotlight and press return . Type " caffeinate -t 18000"  in the terminal. This will keep your MAC awake for 18000 miliseconds or 5 hours. If you want to wake it up before that, hit CMD+C. If you want to make it awake for undetermined time, type only  caffeinate  and hit CMD+C when you want to awake. ➜   ~ caffeinate -t 18000

Let your MAC speak | Cool terminal commands Part1

This might sound strange, but you can actually make your MAC speak. There is a command say Open the terminal , type "terminal" in the spotlight, and hit enter. This will open up the terminal. Type 'say' in the terminal and press enter. It enters into the prompt state, now it will speak whatever you type. Try typing "Hello world", your intelligent MAC will speak the exact words. Press CMD+C when you wish to exit. ➜   ~ say Hello Shubham, it's your mac talking ~Kindly let me know in the comments section if you find this interesting. Happy coding :)

The most used but overlooked data structure | Learn Data Structure with Shubham part 4

 TRIE  Trie data structure      or (radix tree(radix trie is compressed trie), prefix tree, digital tree)          A trie, also called digital tree or prefix tree, is a kind of search tree—an ordered tree data structure used to store a dynamic set or associative array where the keys are usually strings. Unlike a binary search tree, no node in the tree stores the key associated with that node; instead, its position in the tree defines the key with which it is associated; i.e., the value of the key is distributed across the structure              Advantages: 1. Sometimes Space-Efficient. If you're storing lots of words that start with similar patterns, tries may reduce the overall storage cost by storing shared prefixes once.              2. Efficient Prefix Queries. Tries can quickly answer queries about words with shared prefixes, like: How many words start with "choco...

BFS and DFS | Learn Data Structure with Shubham part 3

Image
Let us tackle with the fear of BFS and DFS. While both BFS and DFS are algorithms for traversing or searching tree or graph data structures. Let us dive into more details about their implementation, applications and time complexity. BFS Input Graph:  Output in BFS: ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K"] What is BFS:  Breadth-first search (BFS) is an algorithm for traversing or searching tree or graph data structures. It starts at the tree root (or some arbitrary node of a graph, sometimes referred to as a 'search key'), and explores all of the neighbour nodes at the present depth prior to moving on to the nodes at the next depth level.   Implementation for BFS: Time Complexity of BFS: The time complexity can be expressed as O(|V|+|E|), since every vertex and every edge will be explored in the worst case. |V| is the number of vertices and |E| is the numb...