Home

Find the Index of the First Occurrence in a String

Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Example 1: Input: haystack = ...

3 Sum-closest

Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of ...

3Sum

Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] ...

GraphQL server with Gqlgen and PostgreSQL

Create graphQL server using gqlgen following gqlgen tutorial mkdir gqlgen-users cd gqlgen-users go mod init github.com/[username]/gqlgen-users Create tools.go with gqlgen ...

Using GORM library to access postgreSQL with JSONB field with GoLang

This tutorial demonstrates how to 'auto migrate' the DB and how to store and retrieve data  from JSONB field in ...

Sign, Verify and decode JWT

  https://github.com/ToniNichev/tutorials-encodeDecodeJWT Json Web Token become widely popular for creating data with optional signature and/or optional encryption and payload. JWTs ...

In-app purchase with server to server notifications

 GitHub Repo
  • Contains these projects:
    • iOS-App (The iOS app that could be used to test the in-app purchase)
    • ...

Adding Google sign-in in iOS with SwiftUI

 Git Hub Repo Google also has a great tutorial here: Get started with Google Sign-In for iOS and macOS Pre-requirements: ...

Using EnvironmentObject to share data between views

// // ContentView.swift // Test // // Created by Toni Nichev on 1/3/24. // import SwiftUI // Our observable object ...

Set up GraphQL with gqlgen and golang

The goal: setting up GraphQL server using Gqlgen library. We are going to set up GraphQL server with Users, and ...

Different ways to use oAuth in your WebAp

Using full redirect This way after clicking on log-in button user is redirected to the sign-in page with all sign-in ...

Zigzag Conversion

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display ...

Using mkcert to create locally-trusted development certificates.

mkcert git repo Creating certificate files
  1. Navigate to desired location where the certificate will be created (for example $ ...

Log In With Apple using redirect pop-up

This tutorial demonstrates how to use oAuth to sign-in with Apple without using any library.We simply use HTTP GET request ...

Using Oauth2 to sign-in users with Apple using Java Script Library

Example project here <html> <head> <style> h1 { text-align: center; } #welcomePanel { display: none; text-align: center; } #signInPanel h2 ...

Sign-in with Apple prerequisite

In order to add Sign-In with Apple we have to do the following:
  1. Create an App ID.
  2. Create a ...

Using oAuth2.0 to sign-in with Google using redirect method

No library required Log In With Google Example In this example we have the main app (in this case my ...

Using Oauth2 to sign-in users with Google using Google Java Script Library

Example project here:  Sign-in with Google using Google Java Script library
  • Main project
<head> <style> #signIn { width: ...

Using JavaScript find to search array of object

var arr = [ {one: 1}, {one: 2} ] var result = arr.find( obj => obj.one > 1 ); console.log(result); ...

Simple use of Java Script spread operator

Converting array into object // The array var numbers = [1,2,3]; var obj = {...numbers } console.log(obj) // result: {0:1, ...

Longest Common Substring

Given two strings text1 and text2, return the length of their longest common subsequenceIf there is no common subsequence, return 0. A subsequence of a string is a new ...

Copy List with Random Pointer

A linked list of length n is given such that each node contains an additional random pointer, which could point to any ...

Range Sum of BST

Given the root node of a binary search tree and two integers low and high, return the sum of values of all nodes with a value ...

Graph traversal

The graph The graph represent connections between airports. Nodes (vertices)  represent airports, and  edges represent flights. BFS search (Breadth First ...

Moving Average from Data Stream

Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window ...

Heaps or priority queues in Java Script

Still work in progress ... Part I Heapify ... Part II sort and heapify We start swapping values and heapify ...

Implement pow(x, n)

Implement pow(x, n), which calculates x raised to the power n (i.e., xn). Example 1: Input: x = 2.00000, n = 10 Output: 1024.00000 Example 2: ...

regular JavaScript functions vs array functions

Does not have its own bindings to this or super, and should not be used as methods. var obj1 = { a: 123, b: ...

JavaScript call, bind and apply simple

According MDN all three methods are very similar, and at the end they produce very similar result.

Longest Common Prefix

Write a function to find the longest common prefix string amongst an array of strings. If there is no common ...

Roman to Integer

Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol                Value I 1 V ...

Container With Most Water

Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two ...

How to solve “Can’t perform a React state update on an unmounted component”

The scenario - Let's imagine that you have a card component that you could show and hide with a button ...

Install SonarQube and add it as a verification step in Jenkins

Install SonarQube Instructions Install SonarQube. This is a reporting tool. $ brew install sonar But it also requires Sonar-scanner in ...

Working with danger JS and integrating it with GitHub

What is danger JS ? Danger runs during your CI process, and gives teams the chance to automate common code ...

Adding continuous integration with Jenkins pipeline and Github webhooks

Pre requirements:
  • Windows, Linux or OSX machine running latest Java JDK or JRE.
  • Github account
  • You could fork the ...

Using Nginx as a reverse proxy and add source code replacement

Task: I have web app (in my case Node app running on port 3000) I would add Nginx in front ...

Unique-paths

A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only ...

Intersection of Two Linked Lists

Write a program to find the node at which the intersection of two singly linked lists begins. For example, the ...

Check if string has all unique characters

Implement an algorithm to determine if a string (of characters from ‘a’ to ‘z’) has all unique characters or not ...

LRU Cache

Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the ...

Trapping Rain Water

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water ...

Web Components: create text field with autosuggest dropdown and dictionary

What are web components? Web components are new reusable components that add new functionalities to a standard components (ie: img, ...

Array VS Hash Table

Hash table tutorial Find element in Array function fuindInArray() { var t0 = performance.now(); for(var q = 0; q < ...

Sort an array

Given an array of integers nums, sort the array in ascending order. Example 1: Input:  [5,2,3,1] Output: [1,2,3,5] Example 2: Input: ...

Majority element in array

Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times ...

Creating loader component and set up one CSS per brand.

Previous solution was great but not perfect. We still add a CSS of two brands in one CSS file and ...

Adding multiple brands and applications

Let's make the task more challenging and assume that we are going to have two different Brands (or apps) one.localhost.com, ...

Adding html.js component

Let's clean up the code a bit and move the html code from ./ssr-server.js to a separate component called html.js ...