Skip to content

Instantly share code, notes, and snippets.

@pravynandas
pravynandas / github_remove_secret_files_history.sh
Last active November 28, 2023 15:00
Delete files with secrets in git history - github
#!/bin/bash
while read -r line; do
if [[ $line == *"blob id:"* ]]; then
# echo "$line"
arrIN=(${line//:/ })
blobId=${arrIN[4]}
echo "blob id:$blobId"
pathx=$(git rev-list --all --objects | grep $blobId)
# echo "$pathx"
@pravynandas
pravynandas / most_important_git_commands.sh
Last active November 27, 2023 21:01
THE MOST IMPORTANT GIT commands
# To get all users' email addresses
git shortlog -sne > .gituserlist
# To UPDATE all user's email address for a give list
# CORRECT NAME <correct_email> INCORRECT NAME <incorrect_email>
# Install filter-repo from newren/git-filter-repo and move `git-filter-repo` binary to git-core folder (git --exec-path)
git filter-repo --mailmap .gitmailmap --force
# To merge other repository's commit into current repo
# Make sure both repo's don't have merge conflicting files/folders first
@pravynandas
pravynandas / mongoose_array_push_example.js
Created November 21, 2023 02:00
Push an item into an array type in mongo db through mongoose
let options = { "upsert": true, "new": true };
let update = { "$push": { } };
update["$push"]["receipts"] = url;
Tran.findByIdAndUpdate(id, update, options, function(err, tran) {
if (err) {
res.status(500).json({ error: err.message })
} else {
res.status(200).json({ message: 'Item pushed successfully.' });
}
@pravynandas
pravynandas / template.pug
Created November 8, 2023 14:47
pub template to include styles in head section
doctype html
html(lang="en")
head
title= pageTitle
//- link(rel="stylesheet" href="statement.css")
style table td {
| border: 1px solid black;
| }
| table {
| border: 2px solid #200e91;
@pravynandas
pravynandas / nodejs_event_emitter_example.js
Created October 26, 2023 16:43
Event Emitter Example in NodeJs
const EventEmitter = require('events');
class MyStream extends EventEmitter {
constructor() {
super();
}
write(data) {
this.emit('data', data);
}
}
@pravynandas
pravynandas / loop_csv_entries.sh
Created October 2, 2023 14:59
Read csv string into a variable as an array and loop through each element (removing extra spaces).
#!/bin/bash
IFS=,
str="Item1, Item2"
read -ra LIST <<<"$str"
for i in "${LIST[@]}"; do echo "$i" | xargs; done
@pravynandas
pravynandas / modSaveMail.bas
Created March 2, 2023 14:41
Outlook VBA Macro - Save Email and Attachments to Disk
Option Explicit
Private Const gAttachmentSizeMin As Long = 10240 '10 KB
Public Sub Backup_Email(ByRef objMsg As Outlook.MailItem)
Dim objOL As Outlook.Application
Dim objAttachments As Outlook.Attachments
Dim objSelection As Outlook.Selection
Dim i As Long
Dim lngCount As Long
Attribute VB_Name = "ModStdIO"
Option Explicit
Private Declare Function GetStdHandle Lib "kernel32" (ByVal nStdHandle As Long) As Long
Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, _
lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, _
lpNumberOfBytesRead As Long, lpOverlapped As Any) As Long
Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As Long, _
lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, _
lpNumberOfBytesWritten As Long, lpOverlapped As Any) As Long
@pravynandas
pravynandas / main.js
Created February 12, 2020 16:17 — forked from Jagathishrex/main.js
converting string to camel case
// util function to convert the input to string type
function convertToString(input) {
if(input) {
if(typeof input === "string") {
return input;
}
@pravynandas
pravynandas / functionList.xml
Created October 5, 2017 07:54
Notepad++ Function list for VB (.NET) files
<?xml version="1.0" encoding="UTF-8" ?>
<!--
For learning making your language parser, please check the following link:
http://notepad-plus-plus.org/features/function-list.html
-->
<NotepadPlus>
<functionList>
<associationMap>
<!-- langID:
L_TEXT: 0 L_PHP: 1 L_C: 2 L_CPP: 3 L_CS: 4 L_OBJC: 5