Skip to content

Instantly share code, notes, and snippets.

View tanvirstreame's full-sized avatar
💻
Superman

Tanvir Islam Streame tanvirstreame

💻
Superman
View GitHub Profile
function repeatDigitUntilOne(num) {
while (num > 9) {
num = num.toString().split('').reduce((sum, digit) => parseInt(sum) + parseInt(digit), 0)
}
return num;
}
console.log(repeatDigitUntilOne(38))
console.log(repeatDigitUntilOne(0))
@tanvirstreame
tanvirstreame / gist:948b2c676b1704acee4e07e707a40bdb
Last active May 19, 2024 06:30
Facebook system (Keeping list/map inside each class)
class User {
constructor() {
if (!User.users) {
User.users = new Map();
}
}
static registerUser(userId, userName) {
if (!User.users.has(userId)) {
const newUser = { userId, userName };
@tanvirstreame
tanvirstreame / gist:4f682ead91d03c39c697a56234677ba1
Created May 19, 2024 06:16
Facebook System ( list/ map outside of the class)
class User {
constructor(userId, userName) {
this.userId = userId;
this.userName = userName;
}
}
class Post {
constructor(userId, posts) {
this.userId = userId;
@tanvirstreame
tanvirstreame / gist:569e8adac39d9c3e60491b5b2dda21a9
Created May 19, 2024 03:59
Twiller (Keep list / map outside of class)
class User {
constructor(userId, fullName, phone, age) {
this.userId = userId;
this.fullName = fullName;
this.phone = phone;
this.age = age;
}
}
class Follow {
@tanvirstreame
tanvirstreame / gist:5c913537a258fb643435f34781b71588
Created May 19, 2024 03:58
Twitter (keeping list/map inside class)
class User {
constructor() {
this.users = new Map();
}
registerUser(userId, fullName, phone, age) {
if (!this.users.has(userId)) {
const newUser = { userId, fullName, phone, age };
this.users.set(userId, newUser);
return newUser;
class User {
registerUser(userId, userName) {
this.userId = userId;
this.userName = userName;
return "User Created";
}
get() {
return {
userId: this.userId,
class User {
constructor(userId, userName) {
this.userId = userId;
this.userName = userName;
}
}
class Post {
constructor(userId, posts) {
this.userId = userId;

Definitely not comprehensive. This is meant to be a basic memory aid with links to get more details. I'll add to it over time.

Install

$ npm install mongoose --save

Connect

const mongoose = require('mongoose');
const arr = [4,2,1,3];
class Node {
constructor(value) {
this.value = value;
this.next = null;
}
}

Some helpful guidelines for pull requests and code reviews

It's been often said that programming is part art, part science - that because lots of times there's no single, simple solution to a problem; or if there is, we might not know about it. There's also an infamous joke that if there are n developers in the room, then there are n+1 opinions on how things should be done. That being said, here are some guidelines that should prevent friction when submitting or reviewing code.

The most important thing

The code has to work. Unless you open a PR as a work in progress, the code should be built and tested on a device or emulator.

If you have touched the gradle build files and changed build setup, it's useful to test the whole build from scratch (clean build) and all of the types and flavours. If you have touched payments (logic or UI), you should test that it still works correctly, both in test and production builds. If you updated external libraries, test the pertaining features (e.g. if you