Skip to content

Instantly share code, notes, and snippets.

View anonymoustafa's full-sized avatar

Mostafa Ramezani anonymoustafa

View GitHub Profile
@anonymoustafa
anonymoustafa / node-core-modules.md
Created June 21, 2022 10:57
How to get an exact list of Node core modules

Do this in the REPL mode: console.log ( require('repl')._builtinLibs ); Or put this line of code in your app.js file and execute: console.log ( require('repl')._builtinLibs ); return;

@anonymoustafa
anonymoustafa / mongodb-authentication-error.md
Created May 27, 2022 14:09
Solution to the MongoDB authentication error

You can find the same question [here][1] I just encountered this error:

    Server is running on port: 5000
MongoServerError: bad auth : Authentication failed.
    at Connection.onMessage (/home/mostafa/documents/local-repositories/mern-mongodb-tutorial/server/node_modules/mongodb/lib/cmap/connection.js:202:30)
    at MessageStream.<anonymous> (/home/mostafa/documents/local-repositories/mern-mongodb-tutorial/server/node_modules/mongodb/lib/cmap/connection.js:62:60)
    at MessageStream.emit (node:events:527:28)
    at processIncomingData (/home/mostafa/documents/local-repositories/mern-mongodb-tutorial/server/node_modules/mongodb/lib/cmap/message_stream.js:108:16)

at MessageStream._write (/home/mostafa/documents/local-repositories/mern-mongodb-tutorial/server/node_modules/mongodb/lib/cmap/message_stream.js:28:9)

@anonymoustafa
anonymoustafa / index.js
Created May 6, 2022 17:44
simplest-react-index.js files ever
import React from 'react';
import ReactDOM from 'react-dom/client';
const root = ReactDOM.createRoot(document.getElementById("root"));
const element = <h1> Hello, world </h1>;
root.render(element);
// link to the main tweet: https://twitter.com/iam_vee/status/1517357609170386944?s=20&t=MN3UgYbDae5NCTSoeh5mzg
var sum = 0, counter = 0,
maxTries = 1000_000;
for (let i = 1; i <= maxTries; i++) {
counter++;
while (1) {
sum++;
if (gimmeRand1to6() == 6) break;
}
}
// Link to main question ==> https://twitter.com/Loc0m0/status/1508697606716764162?s=20&t=Ziozpzj6KIznNArdT9n3xQ
const splicer = function () {
let accumulator = "";
for (let i = 1; i <= 100_000; i++) {
accumulator = accumulator + "0" + i.toString();
}
let arrayOfStrings = accumulator.split("0");
let arrayOfNumbers = arrayOfStrings.map(Number);
let result = arrayOfNumbers.reduce((sum, current) => sum + current, 0);
console.log(result);
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific environment
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
then
@anonymoustafa
anonymoustafa / v-lang
Last active January 19, 2022 07:42
When installing vlang on fedora, do these steps or it won't work.
$ sudo dnf install libatomic
$ sudo ./v symlink
@anonymoustafa
anonymoustafa / .vimrc
Last active July 5, 2022 07:11
my .vimrc configuartions
set nocompatible " be iMproved, required
set autochdir " when making new file, the pwd is the path. not the root.
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
@anonymoustafa
anonymoustafa / triangle.0.0.1.js
Created December 17, 2021 11:04
Drawing triangles in terminal using nodejs.
let s = "*";
for (; s.length < 99; s = "*" + s)
console.log(s);
@anonymoustafa
anonymoustafa / fibbo-series.0.0.2.js
Created December 17, 2021 10:52
A more complete Fibonacci series calculator. Written in NodeJS
const readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
// ask user for the name input
rl.question(`What Fibbonacci sentence do you want to calculate? `, (last_fibbo_sentence) => {