Skip to content

Instantly share code, notes, and snippets.

View rocktimsaikia's full-sized avatar
🐰
always learning

Rocktim rocktimsaikia

🐰
always learning
View GitHub Profile
@rocktimsaikia
rocktimsaikia / index.js
Last active December 6, 2019 15:30
Use .hbs as file extension for express handlebars.
const express = require('express');
const exphbs = require('express-handlebars');
app.engine('.hbs', exphbs({extname: '.hbs'}));
app.set('view engine', '.hbs');
// Now you can use `.hbs` as file extension for express-handlebars
@rocktimsaikia
rocktimsaikia / install_nodejs_on_wsl.md
Last active August 15, 2020 19:57
Steps to install windows subsystem for linux ⚡

Installing nodejs in Windows Subsystem for Linux (WSL) ⚡

Assuming that you already have WSL installed in your windows.

Steps

  1. update Ubutu to it's latest version. Don't if you already have.

sudo is equivalent to running as administrator

sudo apt-get update
@rocktimsaikia
rocktimsaikia / git_commands.md
Created August 15, 2020 20:16
Most used git commands

Initialize Git: git init

et everything ready to commit: git add .

et custom file ready to commit: git add index.html

ommit changes: git commit -m "Message"

ommit changes with title and description: git commit -m "Title" -m "Description..."

@rocktimsaikia
rocktimsaikia / paginate.md
Last active January 14, 2021 15:31
🔥 How to paginate in mongodb using mongoose

🔥 Here is how to paginate in MongoDB using mongoose :

// Here it is hardcoded for example but 
// generally the `pageNum` should come from request query param
const pageNum = 2;
const pageSize = 10;

// pagination formula
const paginate = (pageNum - 1) * pageSize; 
@rocktimsaikia
rocktimsaikia / mongodb.md
Last active January 18, 2021 08:46
🔥 A tiny mongodb command cheatsheet for my personal use. Because I tend to forget them quite often

Common mongo shell commands/methods

show dbs : Show all the databases.
use <database> : switch/move into a database.
show collections : Show all the collections in that database.
db.<collection>.find() : Show all documents in the collection.
db.<collection>.help() : Show help on collection methods.
db.<collection>.drop() : Drops or removes completely the collection.
db.<collection>.deleteMany() : Delete documents from the collection.
db.dropDatabase(): Deletes a database.

@rocktimsaikia
rocktimsaikia / invert.js
Last active March 11, 2021 06:27
Invert an array of integers
// Inverts the integers of an array
const invert = arr => arr.map(n => -n);
invert([2,-5]); //=> [-2,5]

Keybase proof

I hereby claim:

  • I am rocktimsaikia on github.
  • I am rocktimcodes (https://keybase.io/rocktimcodes) on keybase.
  • I have a public key ASAuQYTNFSXBEjGqCDGvRT2LVEDf48FlHEvoVSBnk1I_ggo

To claim this, I am signing this object:

@rocktimsaikia
rocktimsaikia / process.js
Created March 9, 2022 16:33
Node uptime in HH:MM:SS
const uptime = new Date(Math.floor(process.uptime()) * 1000).toISOString().substr(11, 8)

Tmux cheatsheet

ctrl+b+" = Splits the window horizantally
ctrl+c+% = Splits the window vertically
ctrl+d = Drop the current pane
ctrl+b+<arrows> = to switch between pages
ctrl+b+z = Zoom in and out in the current pane
ctrl+b+c = Create a new window
ctrl+b+p = Go to the previous window
ctrl+b+n = Go to the next window \

@rocktimsaikia
rocktimsaikia / vim-cheats.md
Created October 29, 2022 07:54 — forked from Starefossen/vim-cheats.md
My vim cheat sheet for working with tabs and window splits.

Tabs

New Tab

  • :tabnew - new blank tab
  • :tabedit [file] - open file in tab

Cursor Movement

  • gt (:tabn) - next tab