Skip to content

Instantly share code, notes, and snippets.

View MohiuddinAkib's full-sized avatar
🏠
Working from home

mohammad mohiuddin mostafa kamal akib MohiuddinAkib

🏠
Working from home
  • Dhaka, Bangladesh
View GitHub Profile
@MohiuddinAkib
MohiuddinAkib / console_color_code.txt
Created December 26, 2019 08:08
Way of colorizing the console with languages
wrap the text with like this "\033[colorcodemTEXT\033[0m"
Foreground Colors
Color Code
Black 0;30
Dark Grey 1;30
Red 0;31
Light Red 1;31
Green 0;32
Light Green 1;32
@MohiuddinAkib
MohiuddinAkib / main.go
Created December 26, 2019 06:29
Scan user input in go
func main() {
var line string
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
line = scanner.Text()
fmt.Println("Got line:", line)
for _, x := range strings.Fields(line) {
fmt.Println("next field: ",x)
}
}
@MohiuddinAkib
MohiuddinAkib / gist:ebd0170e4d9e55cad3704f8505a6a262
Created December 22, 2019 05:32
Function to get an array of file paths nested inside a directory
const fs = require("fs");
const path = require("path");
const controllersDir = path.join(__dirname, "target_dir");
const files = fs.readdirSync(controllersDir);
const getFiles = files =>
files.reduce((acc, file) => {
const filePath = path.join(controllersDir, file);
@MohiuddinAkib
MohiuddinAkib / deployment_guide.md
Created December 20, 2019 05:23 — forked from vicgonvt/deployment_guide.md
Deployment Guide for Ubuntu Server from Scratch with Laravel
@MohiuddinAkib
MohiuddinAkib / express_spa_csrf.js
Created August 26, 2019 09:05
sending csrf token to spa with csurf library and express.js
app.all('*', function (req, res) {
res.cookie('XSRF-TOKEN', req.csrfToken())
res.render('index')
})
@MohiuddinAkib
MohiuddinAkib / flask_any_route.py
Created August 13, 2019 17:36
Handling any route with python flask
from flask import Flask, render_template, abort
from jinja2 import TemplateNotFound
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def index(path):
try:
return render_template('index.html')
except TemplateNotFound:
abort(404)
@MohiuddinAkib
MohiuddinAkib / linux_bashrc_restore
Created August 2, 2019 16:09
command to restore .bashrc at root if things messes up and no command works
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin
@MohiuddinAkib
MohiuddinAkib / understanding_linux_file_system
Created August 1, 2019 08:31
The basic understanding of linux file system
https://www.youtube.com/watch?v=HbgzrKJvDRw
@MohiuddinAkib
MohiuddinAkib / linux_installing_partition_guide
Last active August 1, 2019 08:27
Understanding the partition system in linux
1. 'dev' refers to device. in my case i have a ssd and a hdd. so while installing linux it will show
one of them as 'dev/sda' and other as 'dev/sdb'. 'sd' refers to disk and adds an alphabet to it's end to alphabetically organize.
2. under each disk we will have partition of that disk. each partition will append a number to organize them. ex: sda1, sda2, sdb1, sdb2 ...
follow this link on Step 4: Partition Magic https://medium.com/@killyourfm/the-beginners-guide-to-installing-ubuntu-linux-18-04-lts-6c8230036d84
The part which is the main focus of this gist:
Sidebar: Here’s how Linux identifies devices. “dev” simply means “a device that you can read from or write to.” Then we see “sda, sda1,
@MohiuddinAkib
MohiuddinAkib / linux_install_on_ssd_and_hdd
Last active August 1, 2019 06:57
The efficient way to utilize the speed of SSD and huge storage capability of HDD while installing linux on machine
[SSD]
/boot
/
[HDD]
/usr
/tmp
/home
SWAP