Skip to content

Instantly share code, notes, and snippets.

View shivanshtalwar0's full-sized avatar

Shivansh Talwar shivanshtalwar0

View GitHub Profile
@shivanshtalwar0
shivanshtalwar0 / Flutter_Responsive.dart
Created May 22, 2021 12:01
bootstrap inspired flutter widget to handle responsive breakpoints to aid in development of scalable user interfaces
import 'package:flutter/widgets.dart';
class Responsive {
bool get isXl => width >= 1200;
bool get isLg => width >= 992 && width < 1200;
bool get isMd => width >= 768 && width < 992;
bool get isSm => width >= 576 && width < 768;
@shivanshtalwar0
shivanshtalwar0 / iptable-port-forwarding-vpn.md
Last active January 12, 2025 10:21
IpTables based port forwarding make sure to disable ufw or set rule to make it work

make pupeteer work on arm64 (raspberry pi or orangepi)

  1. Install deps
sudo apt install chromium-browser chromium-codecs-ffmpeg

and specify flags and path

const browser = await puppeteer.launch({
          headless: true,
 executablePath: '/usr/bin/chromium-browser',
@shivanshtalwar0
shivanshtalwar0 / install-docker-mint20.sh
Created June 8, 2021 22:09 — forked from dnavarrom/install-docker-mint20.sh
Install docker and docker compose en linux mint 20
#docker setup
echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" | sudo tee /etc/apt/sources.list.d/docker.list
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io pigz
#execution permission
sudo usermod -aG docker $USER
#docker compose
@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) {
@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 / 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 / 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 / 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 / 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 / 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'\''"'