Skip to content

Instantly share code, notes, and snippets.

View ManojBuilds's full-sized avatar
💭
😜

Manoj Kumar ManojBuilds

💭
😜
View GitHub Profile
@ManojBuilds
ManojBuilds / main.py
Created February 15, 2024 05:21
Cookie Clicker Solution
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
TIMEOUT = 5
chrome_options = Options()
@ManojBuilds
ManojBuilds / App.js
Created January 17, 2024 05:10
Tailwindcss (nativewind) is not working on web version in expo app?
// Paste this code inside your App.js
import { NativeWindStyleSheet } from 'nativewind';
NativeWindStyleSheet.setOutput({
default: "native"
})
@ManojBuilds
ManojBuilds / timestamp-microservice.js
Created September 28, 2023 02:23
Timestamp Microservice: Freecodecamp
// index.js
// where your node app starts
// init project
var express = require('express');
var app = express();
// enable CORS (https://en.wikipedia.org/wiki/Cross-origin_resource_sharing)
// so that your API is remotely testable by FCC
var cors = require('cors');
@ManojBuilds
ManojBuilds / index.html
Created September 22, 2023 03:13
Speech to text in javascript
<div class="container">
<button id="start">start</button>
<button id="stop">stop</button>
<p id="result">Hello</p>
</div>
@ManojBuilds
ManojBuilds / Create-sanity-project-with-nextjs.md
Last active September 20, 2023 03:54
Create sanity project with nextjs

Setup sanity cli by running this command:

npm install --global sanity@latest

Create sanity project with nextjs by running this command:

npx sanity init
@ManojBuilds
ManojBuilds / cash-register.js
Created September 4, 2023 11:51
Cash Register: freeCodeCamp
function checkCashRegister(price, cash, cid) {
let change = [];
let changeDue = cash - price;
console.log('dueAmount:',changeDue);
const currency = {
PENNY: 0.01,
NICKEL: 0.05,
DIME: 0.1,
QUARTER: 0.25,
ONE: 1,
@ManojBuilds
ManojBuilds / telephone-number-validator.js
Created September 4, 2023 11:25
Telephone Number Validator: freeCodeCamp
function telephoneCheck(str) {
const phoneRegex=/^(1 |1)?((\d{3})|(\(\d{3}\)))(-| |)(\d{3})(-| |)(\d{4})$/;
//breakdown
// ^(1 |1) starts with 1 whitespace or 1 and this is optional this may or may not be present;
// ((\d{3})|(\(\d{3}\))) braket and consecutive 3 digit or with whitespace
// (-| |) - and whitespace after that or no -
// (\d{3}) three digit
// (-| |) - and whitespace after that or no -
// (\d{4})$ and end with four digit
return phoneRegex.test(str)
@ManojBuilds
ManojBuilds / roman-numeral-converter.js
Created September 4, 2023 09:27
Roman Numeral Converter: Convert the given number into a roman numeral. freeCodeCamp
function convertToRoman(num) {
// Decreasing order of the value is important because we substract the value from the num
// eg:To represent the number 4, you would write 'IV.' In this case, 'I' (1) is subtracted from 'V' (5), resulting in 4.
const romanNumerals = [
{ value: 1000, numeral: 'M' },
{ value: 900, numeral: 'CM' },
{ value: 500, numeral: 'D' },
{ value: 400, numeral: 'CD' },
{ value: 100, numeral: 'C' },
{ value: 90, numeral: 'XC' },
@ManojBuilds
ManojBuilds / palindrome-checker.js
Created September 4, 2023 09:06
Palindrome Checker- FreeCodeCamp: Return true if the given string is a palindrome. Otherwise, return false. A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing. Note: You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn every…
function palindrome(str) {
const palindromeRegex=/[^a-zA-Z0-9]/ig; // regex for remove all non blank characters from the string
const res= ''.concat(str).replace(palindromeRegex,'').toLowerCase(); //remove all non blank characters from the string, after removing non alphabatic characters convert all into lowerCase or upperCase
// Check for every characters in str by spliting the str and comparing with reversed array after spliting
for(let i=0;i<res.split('').length;i++){
let char=res.split('')[i];
let reverseChar=res.split('').reverse()[i];
if(char!==reverseChar){
// check the char with reverse char with same position
return false;
@ManojBuilds
ManojBuilds / map-the-debris.js
Created September 4, 2023 04:51
FreeCodeCamp: According to Kepler's Third Law, the orbital period T of two point masses orbiting each other in a circular or elliptic orbit is: T=2πa3μ−−−√ a is the orbit's semi-major axis μ=GM is the standard gravitational parameter G is the gravitational constant, M is the mass of the more massive body. Return a new array that transforms the e…
// Define a function called orbitalPeriod that takes an array 'arr' as input.
function orbitalPeriod(arr) {
// Define constants for GM (gravitational constant * Mass of Earth) and Earth's radius.
const GM = 398600.4418;
const earthRadius = 6367.4447;
// Use the map() method to transform the input array.
const result = arr.map((item) => {
// Calculate the semi-major axis for the current element.
const semiMajorAxis = earthRadius + item.avgAlt;