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
/**
* Account class (Parent class)
* @constructor
*/
var Account = function() {
this.amount = 0;
this.setAmount = function(amount) {
this.amount = amount;
@eftakhairul
eftakhairul / LEMP-server
Last active July 10, 2017 15:47
Create lamp-server
#!/bin/sh
##################################################################################
# Bash script to install an LEMP stack plus tweaks. For Ubuntu based systems.
# Written by @eftakhairul from https://eftakahirul.com
#
#
# RUN: bash <(curl -s https://gist.githubusercontent.com/eftakhairul/74670f8ba96bcf6efcecb28f238aa3b7/raw/f43cc5deaac1bcc20657e6bd3a1455441c1795d6/LEMP-server)
###################################################################################
@eftakhairul
eftakhairul / db_backup.sh
Last active September 14, 2018 03:19
Dump your db using bzip2 compression
#!/bin/sh
# Creates database backups using mysqldump. It uses bzip2 for compression, and
# the filename of the dump is DB- and the current timestamp. The dumps are stored
# in ARCHIVE_DIR and bzip2 is called with nice to make it softer on the server.
ARCHIVE_DIR=~/backup
FILENAME=$(date '+%Y-%m-%d_%H:%M:%S')
USER=root
PASS=your_db_password
@eftakhairul
eftakhairul / golang_job_queue.md
Created February 28, 2018 20:45 — forked from harlow/golang_job_queue.md
Job queues in Golang
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 / 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"
@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 / 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.
*/
#!/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 / 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