CᴏᴅɪɴɢNᴇʀᴅ 💸🐾
99 subscribers
118 photos
3 videos
15 files
40 links
༗ हरे कृष्णा ༗
"Lost in my own cosmos 💫 | Coding Need Patience 🥀🐾"

❝Face the failure, Until the Failure fails to face you.❞

— Dreamer

» ChikuX69.netlify.app «

DM ? " @ChikuXBot " : 404;
Download Telegram
Day 74👾:
Design a data structure that works like a LRU Cache. Here cap denotes the capacity of the cache and Q denotes the number of queries. Query can be of two types:

PUT x y: sets the value of the key x with value y
GET x: gets the value of key x if present else returns -1.
The LRUCache class has two methods get() and put() which are defined as follows.

get(key): returns the value of the key if it already exists in the cache otherwise returns -1.
put(key, value): if the key is already present, update its value. If not present, add the key-value pair to the cache. If the cache reaches its capacity it should remove the least recently used item before inserting the new item.
In the constructor of the class the capacity of the cache should be initialized.
2👍21🔥1🖕1
Day 75👾:
Given a string s, which may contain duplicate characters, your task is to generate and return an array of all unique permutations of the string. You can return your answer in any order.
👍21🔥1👏1
Day 76👾:
Implement the function power(b, e), which calculates b raised to the power of e (i.e. b^e).
🔥2👏21👍1
🖤🕯️
2😢2👍1🙏1
Day 77👾:
The n-queens puzzle is the problem of placing n queens on a (n × n) chessboard such that no two queens can attack each other. Note that two queens attack each other if they are placed on the same row, the same column, or the same diagonal.

Given an integer n, find all distinct solutions to the n-queens puzzle.
You can return your answer in any order but each solution should represent a distinct board configuration of the queen placements, where the solutions are represented as permutations of
[1, 2, 3, ..., n]. In this representation, the number in the ith position denotes the row in which the queen is placed in the ith column.
For eg. below figure represents a chessboard
[3 1 4 2].
👏3👍21
Completed 77 Day Of Coding 🎉
🔥3👍2🤩21
This media is not supported in your browser
VIEW IN TELEGRAM
👍2🔥1🥰1🎄1😘1
print(7 > 6 > 5)
Anonymous Quiz
79%
True
21%
False
👍3👎1
New Junior Developers Can’t Actually Code??


Read This Blog:
https://nmn.gl/blog/ai-and-learning
👍3🤷‍♀2🔥2👀1
° Figlet Design using node.js

→ First Install Node.JS in your system, if you don't have node.js!
Check This Post for Node installation (Note: Install only node, not tailwind)



→ Verify the installation using node -v command in terminal


› Now Follow these steps:-

• Open VS Code and make a separate folder, then open that folder in terminal
In terminal, do this
npm install figlet



• You will see some file and folders created, don't touch them. Simply make a JS file (example: index.js)


• Copy and paste this code in that JS file
let figlet = require('figlet');
let input = process.argv.slice(2).join(' ');

figlet(input, function (err, data) {
if (err) {
console.log("Something went wrong...");
console.dir(err);
return;
}
console.log(data);
});



• Usage: In the terminal use this command
node index.js "Your Text"


• Note: If you made your JS file with any other name then replace this index.js and use your file name.

@NotCoding | @CodesSnippet

Happy Coding 👨‍💻
👍2🔥2🥰1👏1
console.log("abc".toLowerCase === "xyz".toLowerCase);
Anonymous Quiz
39%
true
48%
false
12%
error
1👍1
महाशिवरात्रि की हार्दिक शुभकामनाएं ❤️🙇‍♂
2👍2🙏1
def getPrint(name="world", some):
print(f"Hello {name}")
getPrint("Chiku", 55)
Anonymous Quiz
24%
Hello World
39%
Hello Chiku
12%
Hello 55
24%
Error
👍2🔥1
Source - ByteByteGo 👾
👍51🔥1
Yes, We won ❤️🥀🇮🇳😭
4🔥2👍1
होली की हार्दिक शुभकामनाएं ❤️
👍32🥰1
•• Basic Authentication For Web API ••

› So, What is Authentication and why we need it?
Basically, In simple words Authentication is the process of verifying the identity of a user or client before giving access to API routes, data, or features in a web API.


› We are going to implementation a basic "
Token" based authentication.

› For This we need node.js installed in our Local Mechine / Server, If don't have installed that checkout this post for step by step node installation (NOTE: Only Install Node.js Part).



Implementation:

› At First, Setup your project by doing basic initialization in a specific project's folder.
npm init -y


› Now, we are going to install a package called express.js for our backend.
npm install express


or
npm i express


› Now, create a .js file give a specific and logical name to it (example: index.js)

› Code:
We are going to implement it using request headers:
const express = require("express");
const app = express(); // defining express

// it need to define request header at every api call
const auth = (req, res, next) => {
let {token} = req.headers;
if (token === "giveAccess") { // give your custom token value by removing "giveAccess" (Suggested: use some uuid key)
console.log("Login Successful");
next();
} else {
res.send({error: "Access Denied"});
}
};

// Example route, define your specific route to implement
app.get("/api", auth, (req, res) => {
res.send({message: "Access Granted"});
});


NOTE: This is basic Authentication way to implement it, not recommended in major and production level projects, it's only for your personal projects, API's etc.



Have any suggestion?
› Please Welcome: @ChikuXBot


@NotCoding | @CodesSnippet

Happy Coding 👨‍💻
🔥2👏2👍1
CᴏᴅɪɴɢNᴇʀᴅ 💸🐾
•• Basic Authentication For Web API •• › So, What is Authentication and why we need it? Basically, In simple words Authentication is the process of verifying the identity of a user or client before giving access to API routes, data, or features in a web API.…
Basic Implementation in Python

1. Without API Key Which i defined right now!
requests.get("http://localhost:3010/api")


Output:
{
'error': 'Access Denied'
}



2. With API Key
requests.get("http://localhost:3010/api", headers={"token": "giveAccess"})


Output:
{
'message': 'Access Granted'
}



Try Yourself 🧑‍💻
2👍2👏2🥰1
रामनवमी की हार्दिक शुभकामनाएं ❤️
2👍2
Got it mate!!
👍42🔥2🫡1