Skip to content

Instantly share code, notes, and snippets.

View eftakhairul's full-sized avatar
💭
writing code for spaceship :P

Md Eftakhairul Islam eftakhairul

💭
writing code for spaceship :P
View GitHub Profile
@eftakhairul
eftakhairul / Makefile
Created February 2, 2021 18:55 — forked from kwilczynski/Makefile
Makefile for my Go projects (an example).
SHELL := /bin/bash
REV := $(shell git rev-parse HEAD)
CHANGES := $(shell test -n "$$(git status --porcelain)" && echo '+CHANGES' || true)
TARGET := packer-provisioner-itamae-local
VERSION := $(shell cat VERSION)
OS := darwin freebsd linux openbsd
ARCH := 386 amd64
@eftakhairul
eftakhairul / exportDB.sh
Last active June 16, 2020 21:49
Export mongodb database into JSON files, and import the JSON again.
#!/bin/bash
if [ ! $1 ]; then
echo " Example of use: $0 database_name dir_to_store"
exit 1
fi
db=$1
out_dir=$2
if [ ! $out_dir ]; then
out_dir="./"
@eftakhairul
eftakhairul / System Design.md
Created May 6, 2020 04:34 — 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?
@eftakhairul
eftakhairul / killport
Created April 25, 2020 03:39
killport tool
#!/bin/bash
# Kill process on requested port
# Author: Md Eftakhairul Islam
if [[ $# -eq 0 ]]; then
echo "Port is not specified"
exit 1
fi
#!/bin/bash
iatest=$(expr index "$-" i)
#######################################################
# SOURCED ALIAS'S AND SCRIPTS BY zachbrowne.me
#######################################################
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
@eftakhairul
eftakhairul / ES5 class.js
Created August 29, 2019 04:22 — forked from apal21/ES5 class.js
Example for blog to show the difference between ES5 and ES6 javascript classes using inheritance and prototypes use cases.
'use strict';
/**
* Person class.
*
* @constructor
* @param {String} name - name of a person.
* @param {Number} age - age of a person.
* @param {String} gender - gender of a person.
*/
@eftakhairul
eftakhairul / config.go
Created January 28, 2019 06:14 — forked from chazcheadle/config.go
Golang Viper config read into struct
package main
import (
"fmt"
"github.com/spf13/viper"
)
// Create private data struct to hold config options.
type config struct {
@eftakhairul
eftakhairul / regexCheatsheet.js
Created January 15, 2019 15:59 — forked from sarthology/regexCheatsheet.js
A regex cheatsheet 👩🏻‍💻 (by Catherine)
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
const fileDownload = (req, res, next) => {
const requestedFileName = `${req.params.id}:${req.params.filename}`;
const filePath = path.join([req.app.get('basedir'), 'storage'].join('/') , requestedFileName);
if (!fileSystem.existsSync(filePath)) {
return res.status(403).send({error: 'FileNotExists'}).end();
}
const stat = fileSystem.statSync(filePath);
const filename = path.basename(filePath);
@eftakhairul
eftakhairul / golang_job_queue.md
Created February 28, 2018 20:45 — forked from harlow/golang_job_queue.md
Job queues in Golang