Skip to content

Instantly share code, notes, and snippets.

View ats1999's full-sized avatar
💭
I may be slow to respond.

Rahul kumar ats1999

💭
I may be slow to respond.
View GitHub Profile

Embedding iframe on @dsabyte online editor

When publishing posts, you might often need to embed any content from some other website. You can just use the native iframe tag to embed any post.

Example - LinkedIn embed -still working ..

code

<iframe src="https://www.linkedin.com/embed/feed/update/urn:li:share:6857907035879698432" frameborder="0" allowfullscreen="" title="Embedded post"></iframe>

Output

<iframe src="https://www.linkedin.com/embed/feed/update/urn:li:share:6857907035879698432" height="250" width="100%" frameborder="0" allowfullscreen="" title="Embedded post"></iframe>
@ats1999
ats1999 / problem.md
Created October 23, 2021 14:55
Good Subarrays

Good Subarrays

Given an array of integers A. A subarray of an array is said to be good if it fulfills any one of the criteria: 1. Length of the subarray must be even and the sum of all the elements of the subarray must be less than B. 2. Length of the subarray must be odd and the sum of all the elements of the subarray must be greater than B. Your task is to find the count of good subarrays in A. If the count of good subarrays exceeds 10^9 then return 10^9. Input Format

@ats1999
ats1999 / schema.md
Created October 15, 2021 08:19
blog-comment-schema

UI

comment_page-0001

You can see from the UI, there is a post and some comments. Few comments have threads

Tech stack

NodeJs, MongoDB

Current Schema

require("dotenv").config();
const express = require("express");
const bodyParser = require("body-parser");
const cookieParser = require("cookie-parser");
const cors = require("cors");
const morgan = require("morgan");
// middleware
// get item from local storage
export const getLocalStorage = (str)=>{
try {
return localStorage.getItem(str);
} catch (error) {
// cookie is blocked
return false;
}
}

Live users

requirement

  • a user can be part of multiple org
  • a user can be logged on the multiple dashboard at the same time
  • a user can be logged on the multiple dashboard of different org at the same time

REST

return all users, who are logged in the given dashboard,who belongs to the given org.

How to write better code?

The example has been picked from operationsdashboard/src/Demo/Flight/Preflightdata.js

In order to write better code, we should always think about readiblity of code and nameing conventions. Readibility of code make it easy for new developer to adopt the code and make new changes. For example you can see t5, t4, convertTime2, etc in the code. Any new developer can not understant the code directly, he/she must have to read the entire code and understand it's uses.

Old code

  useEffect(() => {
@ats1999
ats1999 / mongo.md
Last active May 2, 2021 11:18
Quick commands for MongoDB

Let's Learn MongoDB commands

Update

Definition

db.collection.update(query, update, options)

syntax

db.collection.update(
package number;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ats1999
ats1999 / AddC.java
Last active February 29, 2020 09:54
Web Application design and development (Rahul kumar)
package rmi;
/**
* This file contains class which have implemention of AddI interface
*/
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
/**
* This class defines add method, which is called by the client.
* @version 1.0