Skip to content

Instantly share code, notes, and snippets.

View mrhm-dev's full-sized avatar
🏠
Working from home

HM Nayem mrhm-dev

🏠
Working from home
View GitHub Profile
// Recursive One
func plusOne(digits []int) []int {
lastIndex := len(digits) - 1
n := digits[lastIndex] + 1
if (n < 10) {
digits[lastIndex] = n
return digits
}
function findWinner() {
const ss = SpreadsheetApp.openByUrl("spread-sheet-link");
const sheet = ss.getSheets()[0];
const values = sheet.getSheetValues(2, 1, 72, 9 );
const rankValues = [
{
name: 'name',
value: 0
},
{
@mrhm-dev
mrhm-dev / app.js
Created May 27, 2021 15:49 — forked from joshnuss/app.js
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./authorization"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection
@mrhm-dev
mrhm-dev / System Design.md
Created January 4, 2021 07:03 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@mrhm-dev
mrhm-dev / install virtualenv ubuntu 16.04.md
Created December 5, 2020 23:57 — forked from Geoyi/install virtualenv ubuntu 16.04.md
How to install virtual environment on ubuntu 16.04

How to install virtualenv:

Install pip first

sudo apt-get install python3-pip

Then install virtualenv using pip3

sudo pip3 install virtualenv 
# sets the proxy cache path location, max size 2g
proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=STATIC:100m inactive=24h max_size=2g;
# transfers the `Host` header to the backend
proxy_set_header Host $host;
# uses the defined STATIC cache zone
proxy_cache STATIC;
# cache 200 10 minutes, 404 1 minute, others status codes not cached
@mrhm-dev
mrhm-dev / config-editor.md
Created June 7, 2020 12:03 — forked from nnja/config-editor.md
Configure git editor

Set which editor git should use.

This is the program that will open during a commit with no -m flag, a merge, a rebase, etc...

Select from any installed editor. Examples:

  • emacs: emacs
  • vi: vi or vim
@mrhm-dev
mrhm-dev / rename.js
Last active July 22, 2021 16:36
Rename bulk amount of files
const fs = require('fs');
const path = require('path');
const filePath = '/Users/hmnayem/Desktop/Demo';
const files = fs.readdirSync(filePath).filter((file) => file.endsWith('.png'));
let count = 54;
const extName = '.png';
files.forEach((file) => {
const oldPath = path.join(filePath, file);
@mrhm-dev
mrhm-dev / media-query.css
Created March 13, 2020 08:54 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
this === global // true
// In browser
this === window // true