Skip to content

Instantly share code, notes, and snippets.

View santosh-rumsan's full-sized avatar

Santosh Shrestha santosh-rumsan

View GitHub Profile
@santosh-rumsan
santosh-rumsan / nx.md
Last active February 21, 2024 18:42
Build nx library with dependencies

Build nx library with dependencies

Add this to nx.json

    "@nrwl/js": {
      "analyzeSourceFiles": true
    }
  }
@santosh-rumsan
santosh-rumsan / npm_publish.sh
Created February 21, 2024 13:12
Build nx library and publish to npm
#!/bin/bash
# Paths to TypeScript libs folder and distribution folder
baseFolder="/media/santosh/SANTOSH/Projects/rumsan/libraries"
typescriptLibsFolder="$baseFolder/libs"
distributionFolder="$baseFolder/dist/libs"
npmrcPath="$baseFolder/play/.npmrc"
# Function to read version from package.json
read_version() {
@santosh-rumsan
santosh-rumsan / jaleshwor-ben.json
Last active May 25, 2023 05:24
jaleshwor-ben.json
{
"totalCollected": 2756,
"totalValidated": 2179,
"totalDailyWagers": 1865,
"totalLandless": 147,
"totalDisabilities": 45
}
@santosh-rumsan
santosh-rumsan / db_backup.sh
Created July 1, 2022 11:06
Automated database backup to Amazon S3
#!/usr/bin/env bash
red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`
ERROR="`tput setaf 1`ERROR:`tput sgr0`"
SUCCESS="`tput setaf 2`SUCCESS:`tput sgr0`"
TIMESTAMP=`date '+%Y-%m-%d %H:%M:%S'`
todayName="$(date +%a)"
todayNumber="$(date +%d)"
@santosh-rumsan
santosh-rumsan / axios-cookies.js
Created November 19, 2019 04:48
Using Axios to programmatically login to a website and requesting a secure page using cookies
const axios = require("axios").default;
const axiosCookieJarSupport = require("axios-cookiejar-support").default;
const tough = require("tough-cookie");
const qs = require("qs");
axiosCookieJarSupport(axios);
const cookieJar = new tough.CookieJar();
let loginAndGetContent = async () => {
try {
@santosh-rumsan
santosh-rumsan / passthrough-example.js
Created November 18, 2019 10:46
Using Stream PassThrough to pass same output buffer to multiple destination
const PDFMake = require("pdfmake");
const AWS = require("aws-sdk");
const nodemailer = require("nodemailer");
const { PassThrough } = require("stream");
//aws: update your AWS credentials
const accessKeyId = "{aws_accesskey}";
const secretAccessKey = "{aws_secret}";
const region = "us-east-1";
@santosh-rumsan
santosh-rumsan / ArrayWithinAnotherArray.js
Last active November 6, 2019 09:38
There are several cases where we need to check if every item of an particular exists within another array.
let queue = {
actions: ["email", "aws"],
results: [
{
success: false,
retryable: false,
action: "aws"
},
{
success: true,
@santosh-rumsan
santosh-rumsan / ERC20.sol
Last active May 9, 2019 05:46
Sample ERC20 Token Contract
//ERC20.sol
pragma solidity ^0.4.20;
// ----------------------------------------------------------------------------
// 'Rumsan' token contract
//
// Symbol : RUMS
// Name : Rumsan Token
// Total supply: 100000000
void string Test(){
return "Rumsan Associatest" ;
}