Posts

Dockerfile

Hey everyone, This article is about the Dockerfile that we use in building container images. It is nothing but a simple text file with instructions to build a custom image. Docker file helps us to provide instructions on what needs to be pulled, what arguments need to be run after building the image, and providing some configurations. FROM : Specifies the base image to use for the build. It is typically the first instruction in a Dockerfile. Example: FROM ubuntu:latest RUN : Executes commands in the shell of the container. These commands are run during the build process to install packages, configure the environment, etc. Example: RUN apt-get update && apt-get install -y python3 COPY or ADD : Copies files or directories from the host machine into the image. COPY is preferred for simple file copying, while ADD has additional features like extracting tar files and downloading files from URLs. Example: COPY app.py /app/ WORKDIR : Sets the working directory for any RUN, CMD, ENTRY...

Regex 101: An Introduction to Regular Expressions for Developers

Regular expressions (regex) are a powerful tool for searching and manipulating text. They allow you to describe patterns of characters that you want to match, rather than specifying every possible combination of characters. In this blog, we will go over some common regex operations and provide examples for each one. Matching a literal string: regex: hello will match the string "hello". Matching any character: regex: . will match any single character. Matching a set of characters: regex: [aeiou] will match any single vowel. Matching a range of characters: regex: [a-z] will match any single lowercase letter. Matching a negated set of characters: regex: [^aeiou] will match any single non-vowel character. Matching zero or one occurrence: regex: a? will match either the string "a" or an empty string. Matching zero or more occurrences: regex: a* will match any string that contains zero or more "a" characters. Matching one or more occurrences: regex: a+ will matc...

Helm Commands Cheatsheet

Hi everyone๐Ÿ˜Ž, Sharing helm commands that I use day to day. helm create: This command creates a chart directory along with the common files and directories used in a chart. Create a new chart with the given name:-  helm create [CHART]

Minimum Bracket Reversal

For a given expression in the form of a string, find the minimum number of brackets that can be reversed in order to make the expression balanced. The expression will only contain curly brackets. If the expression can't be balanced, return -1. Example : Expression : {{{{ If we reverse the second and the fourth opening brackets, the whole expression will get balanced. Since we have to reverse two brackets to make the expression balanced, the expected output will be 2. Expression : {{{ In this example, even if we reverse the last opening bracket, we would be left with the first opening bracket and hence will not be able to make the expression balanced and the output will be -1. Input Format : The first and the only line of input contains a string expression, without any spaces in between.   Output Format : The only line of output will print the number of reversals required to balance the whole expression. Prints -1, otherwise. Note :You don't have to print anything. It has alrea...

Stock Span

Afzal has been working with an organization called 'Money Traders' for the past few years. The organization is into the money trading business. His manager assigned him a task. For a given array/list of stock's prices for N days, find the stock's span for each day. The span of the stock's price today is defined as the maximum number of consecutive days(starting from today and going backwards) for which the price of the stock was less than today's price. For example, if the price of a stock over a period of 7 days are [100, 80, 60, 70, 60, 75, 85], then the stock spans will be [1, 1, 1, 2, 1, 4, 6]. Explanation: On the sixth day when the price of the stock was 75, the span came out to be 4, because the last 4 prices(including the current price of 75) were less than the current or the sixth day's price. Similarly, we can deduce the remaining results. Afzal has to return an array/list of spans corresponding to each day's stock's price. Help him to achi...

Longest Increasing Subsequence

Given an array with N elements, you need to find the length of the longest subsequence in the given array such that all elements of the subsequence are sorted in strictly increasing order. Input Format The first line of input contains an integer N. The following line contains N space separated integers, that denote the value of elements of array. Output Format The first and only line of output contains the length of longest subsequence. Constraints 1 <= N <= 10^3 Time Limit: 1 second Sample Input 1 : 6 5 4 11 1 16 8 Sample Output 1 : 3 Sample Output Explanation Length of longest subsequence is 3 i.e. (5,11,16) or (4,11,16). Sample Input 2 : 3 1 2 2 Sample Output 2 : 2  

Delete node (recursive)

Given a singly linked list of integers and position 'i', delete the node present at the 'i-th' position in the linked list recursively.  Note : Assume that the Indexing for the linked list always starts from 0. No need to print the list, it has already been taken care. Only return the new head to the list.  input format : The first line contains an Integer 't' which denotes the number of test cases or queries to be run. Then the test cases follow. The first line of each test case or query contains the elements of the singly linked list separated by a single space. The second line of input contains a single integer depicting the value of 'i'. Remember/Consider : While specifying the list elements for input, -1 indicates the end of the singly linked list and hence, would never be a list element Output format : For each test case/query, print the elements of the updated singly linked list. Output for every test case will be printed in a seperate line. C...

Popular posts from this blog

MySQL Multi Source Master Slave Replication using GTID

Setting Up PostgreSQL Logical Replication with Docker Compose

Regex 101: An Introduction to Regular Expressions for Developers