Skip to content

Instantly share code, notes, and snippets.

View shivanshtalwar0's full-sized avatar

Shivansh Talwar shivanshtalwar0

View GitHub Profile
@shivanshtalwar0
shivanshtalwar0 / baseService.js
Created January 12, 2025 15:59
baseService.js for prisma core tsed-helper
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseService = void 0;
const lodash_1 = __importDefault(require("lodash"));
const rxjs_1 = require("rxjs");
const prismaMetaMapper_1 = require("./prismaMetaMapper");
class BaseService {
{
"AF": {
"name": "Afghanistan",
"callingCode": 93,
"isoA2": "AF",
"isoA3": "AFG",
"isoNum": 4
},
"AL": {
"name": "Albania",
@shivanshtalwar0
shivanshtalwar0 / grid.sh
Created July 6, 2024 23:20
ffmpeg grid for 4 videos on cuda device
ffmpeg -y -hwaccel cuda \
-i video1.mp4 -hwaccel cuda -i video2.mp4 -hwaccel cuda -i video3.mp4 -hwaccel cuda -i video4.mp4 \
-filter_complex "[0:v]scale=iw/2:ih/2[v0];[1:v]scale=iw/2:ih/2[v1];[2:v]scale=iw/2:ih/2[v2];[3:v]scale=iw/2:ih/2[v3];[v0][v1]hstack[top];[v2][v3]hstack[bottom];[top][bottom]vstack" \
-c:v h264_nvenc -preset fast -b:v 5M output.mp4
@shivanshtalwar0
shivanshtalwar0 / watch.sh
Last active March 13, 2024 16:40
Watch active network connections to vm
alias watch_netstat='watch -n 1 "echo '\''Proto Recv-Q Send-Q Local Address Foreign Address State'\'' && sudo netstat -ant | grep ESTABLISHED | awk '\''\$2 > 0 || \$3 > 0'\''"'
@shivanshtalwar0
shivanshtalwar0 / caddy_docker_compose.yaml
Created September 26, 2023 12:30
caddy_docker_compose.yaml
caddy:
image: caddy:2.7.4
restart: always
volumes:
- caddy_data:/data
- ./Caddyfile:/etc/caddy/Caddyfile
ports:
- 80:80
- 443:443
volumes:
@shivanshtalwar0
shivanshtalwar0 / deployment.md
Created September 8, 2023 11:29
Deploy Nuxt3 application to VPS using github actions

Step 1

Create a directory .github/workflows in root of. your project Create main.yml file in that directory with following content

name: Deploy

# Trigger the workflow on push and
# pull request events on the master branch
on:
@shivanshtalwar0
shivanshtalwar0 / nodejs-cicd-github-actions.md
Created September 7, 2023 23:42 — forked from danielwetan/nodejs-cicd-github-actions.md
Deploy Node.js to VPS using Github Actions

Deploy Node.js to VPS using Github Actions

Steps to deploy Node.js to VPS using PM2 and Github Actions

1. Clone repo to VPS folder

@shivanshtalwar0
shivanshtalwar0 / async_image_vuejs_directive.md
Created April 6, 2023 10:38
Asynchronously load image through Promise in vue js with directive

Create Global Directive

const vueApp=createApp({})
const replaceElementChildrenWithImage = async (el, binding ) => {
    try {
      const image = await binding.value;
      if (image) el.replaceChildren(image);
    } catch (err) {
      console.error("Image can't be resolved seems like url is broken",err);
    }
@shivanshtalwar0
shivanshtalwar0 / graphplotting.js
Last active January 12, 2022 09:47
graph plotting logic
// https://stackoverflow.com/questions/326679/choosing-an-attractive-linear-scale-for-a-graphs-y-axis
var min=89;
var max=173;
var actualHeight=1200; // 500 pixels high graph
var tickCount =Math.round(actualHeight/100);
// we want lines about every 100 pixels.
if(tickCount <3) tickCount =3;
var range=Math.abs(max-min);
@shivanshtalwar0
shivanshtalwar0 / pathToObject.js
Last active April 3, 2024 13:54
this gist gives working example of converting path to object for example it converts string 'band.material.quality' and value to ```js {band:{material:{quality:value}}}```
const object = {
"customer.firstname": "raj",
"customer.lastname": "sharma",
"kop.shak.rap": 99,
"kop.shak.saip": 99,
simon: "regular",
};
function convertPathObjectToObject(object: any) {
function injectInChild(arr: any, val: any, obj: any = {}, k: any = 0) {