Skip to content

Instantly share code, notes, and snippets.

View sbimochan's full-sized avatar
🎩
Sherlock Holmes mode

Bimochan Shrestha sbimochan

🎩
Sherlock Holmes mode
View GitHub Profile
@sbimochan
sbimochan / Mastering Exception Handling and Logging.md
Last active September 30, 2024 07:13
Best practices on exception handling and logging

Mastering Exception Handling and Logging

Introduction

As developers, we know that writing error-free code is nearly impossible. Errors are inevitable, but it's how we handle them that defines the stability and robustness of our applications. This document dives deep into exception handling, best practices, and defensive programming strategies that ensure code resilience. Defensive programming isn't just about catching errors; it's an art of anticipating potential failures and ensuring your software behaves predictably in the face of problems. Effective error handling and meaningful logging are essential components of this mindset.

Exceptions Handling vs Error Handling

Errors represent serious problems that prevent the program from completing its task. In contrast, exceptions are conditions that interrupt the normal flow of the program but can often be handled. Both are types of runtime errors, which means they occur during the program's execution.

@sbimochan
sbimochan / nepal.md
Created September 4, 2024 05:58
Made in Nepal

With ❤️ Made in Nepal

@sbimochan
sbimochan / Js-For-QA.md
Last active September 19, 2024 10:36
Javascript for QA Automation

Javascript for QA Automation

1. An Introduction to JavaScript

JavaScript is an interpreted, powerful, versatile and beginner-friendly programming language that can add interactivity to a website, create servers, create games, etc.

This happens in games, in the behavior of responses when buttons are pressed or with data entry on forms; with dynamic styling; with animation, etc.

2. Fundamentals

2.1 Data Types and Variables

@sbimochan
sbimochan / codeql-local.md
Last active May 26, 2023 09:41
Run CodeQL locally to check your codebase

Install CodeQL CLI from here

codeql database create project-ql --language=javascript
codeql pack download codeql/javascript-queries
codeql database analyze project-ql codeql/javascript-queries --format=sarifv2.1.0 --output=query-results.sarif --download
sudo pip install sarif-tools
sarif html -o venteur-ql-report/summary.html query-results.sarif

Now open the summary.html in your favorite browser

@sbimochan
sbimochan / styles.css
Created May 17, 2022 13:10
Refined Bitbucket custom styles
@import url(https://cdn.jsdelivr.net/gh/tonsky/[email protected]/distr/fira_code.css);
.code-diff {
font-family: 'Fira Code', monospace;
font-weight: 500;
line-height: 23px;
}
@sbimochan
sbimochan / Assignment.md
Last active February 20, 2023 11:18
Coding assignment Javascript Full stack

Coding Assignment

Create a Restful API for CRUD application using expressJs framework and ReactJS with hooks that has following features.

  • Logged in users can create, delete and update their article.
  • Public user can read the article.

It should show the following implementation:

  • Run in multi thread of CPU.
  • Dockerize the api such that it can be run in services like fargate or kubernetes
  • API should have unit tests
@sbimochan
sbimochan / unique-branches.md
Last active January 16, 2023 13:36
Get All unique commits going to staging branch from dev or other

Make sure you pulled all the commits in dev and staging branch

Approriately change if needed for master and staging.

git log origin/staging..origin/dev --oneline --no-merges

Press enter and grab all the result in clipboard

Fire up the console

@sbimochan
sbimochan / work.scpt
Last active December 31, 2021 05:14
Daily work flow automation
#!/usr/bin/osascript
tell application "iTerm2"
tell current session of current tab of current window
split vertically with default profile
split vertically with default profile
write text "cd ~/projects/myFavProject"
write text "code ."
end tell
tell second session of current tab of current window
write text "cd ~/projects/myFavProject"
@sbimochan
sbimochan / songsterrBannerRemover.md
Created April 16, 2021 15:30
Remove annoying banner from songsterr.com

A temporary workaround to remove the banner.

  • Fire up console. Right click-> click Inspect element-> Click console tab
  • Paste following
setInterval(()=> {
  let banner = document.getElementById('showroom');
  banner.remove();
},2000);
@sbimochan
sbimochan / autoRowOpener.js
Last active January 15, 2021 03:47
Open all rows of react-table in new tab. Change 7 to number of columns manually. You might get a pop up blocked in url box while running for first time.
function getColumnIndices(total) {
let indices = [];
//7 because number of column is 7
for (let index = 0; index < total; index += 7) {
indices.push(index);
}
return indices;
}
const allColumns = document.getElementsByClassName('rt-td');
const indices = getColumnIndices(allColumns.length);