Skip to content

Instantly share code, notes, and snippets.

View Terance98's full-sized avatar
🎯
Focusing

Thomas Terance Terance98

🎯
Focusing
  • Kochi
View GitHub Profile
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
//start a session
const session = await <Model>.startSession();
//start a transaction
session.startTransaction();
//pass session as option in every operations
let save = await new.save({ session:session });
// commit the changes if everything was successful
const { v4: uuidv4 } = require('uuid');
const path = require('path');
const rootPath = process.cwd();
const fs = require('fs');
const mkdirp = require('mkdirp')
const puppeteer = require('puppeteer');
const EjsToHtml = require('./EjsToHtml');
const convert = async (templateAttributes) => {
/**
The following is a cheat sheet about user management in MongoDB.
**/
Start mongod with the following command
//Before creating the users
> mongod
//After creating the users
> mongod --auth
@Terance98
Terance98 / README.md
Created May 20, 2020 15:47 — forked from anhldbk/README.md
TLS client & server in NodeJS

1. Overview

This is an example of using module tls in NodeJS to create a client securely connecting to a TLS server.

It is a modified version from documentation about TLS, in which:

  • The server is a simple echo one. Clients connect to it, get the same thing back if they send anything to the server.
  • The server is a TLS-based server.
  • Clients somehow get the server's public key and use it to work securely with the server

2. Preparation

@Terance98
Terance98 / Javascript_Promises.js
Created March 5, 2020 16:02
This gist contains a sample snippet of javascript code that explains pretty well the use of Javascript promises, how to unpack them with then() etc.. This also uses prototype chaining with multiple then() clauses.
//Here the first Promise resolves and then returns Done to the function inside first then(),
//but this function doesn't take any parameters and hence the value "Done" is never used.
// But the value is still being returned from the Promise to the function where it is unpacked.
// The fetchData promise is returned again by the function inside the first then() that unpacked the promise initially.
// This promise then gets resolved with console.log as the input parameter function, which takes one parameter as input and prints it.
// So it should take total 3 seconds to print Done!. This promise makes use of the returned Done value by printing it to the console with console.log()
const fetchData = () => {
const promise = new Promise((resolve, reject) => {
setTimeout(() => resolve('Done'), 1500);
sudo apt-get install macchanger
ip addr //( -- to list all the newtork drivers that are available for mac change)
//From that select wlo1
sudo macchanger -r wlo1 //Assigns a new mac id to the wifi
//To set up a custom mac id
# macchanger -m b2:aa:0e:56:ed:f7 wlo1
Current MAC: 32:cf:cb:6c:63:cd (unknown)
Faked MAC: b2:aa:0e:56:ed:f7 (unknown)
@Terance98
Terance98 / ssh.md
Created September 5, 2019 13:00 — forked from bradtraversy/ssh.md
SSH & DevOps Crash Course Snippets

SSH Cheat Sheet

This sheet goes along with this SSH YouTube tutorial

Login via SSH with password (LOCAL SERVER)

$ ssh brad@192.168.1.29

Create folder, file, install Apache (Just messing around)

$ mkdir test

$ cd test