Skip to content

Instantly share code, notes, and snippets.

View akashdktyagi's full-sized avatar
🎯
Focusing

Akash Tyagi akashdktyagi

🎯
Focusing
View GitHub Profile
@akashdktyagi
akashdktyagi / sh
Created January 16, 2024 10:14
Docker command to mount a volume in docker run
docker run -v /home/akash/vscode/repository:/wow -it registry.gitlab.com/security-products/nodejs-scan:4 /bin/sh
#wow will be automatically created if does not exist
docker run -v /home/akash/vscode/repository:/wow:ro -it registry.gitlab.com/security-products/nodejs-scan:4 /bin/sh
#add ro for read only
@akashdktyagi
akashdktyagi / sh
Created January 16, 2024 10:12
use echo to create or modify an existing file in linux
echo "
---
- nodejs-extensions:
- .js
template-extensions:
- .new
- .hbs
- ''
@akashdktyagi
akashdktyagi / gist:a85442e85f546609b56488dc3e087168
Created January 16, 2024 10:11
Create python virtual env and activate it
python3 -m venv venv
source venv/bin/activate
pip install njsscan
njsscan
// Deactivate
deactivate
@akashdktyagi
akashdktyagi / gist:5d33e0ef4e3a719e9f8f7009b8b0e17c
Created January 15, 2024 13:13
Java Code to Read the Excel file and return a hash map using poi
package com.oncor.ams.core.managers.excel;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@akashdktyagi
akashdktyagi / gist:047ea91273eb0e8f9e19c7baa4b41614
Created December 10, 2023 07:30
Terraform script to create a EC2 instance with docker and nginx preinstall
variable "awsprops" {
default = {
region = "us-east-1"
vpc = "vpc-511de02c" # change this to your vpc id
ami = "ami-051f7e7f6c2f40dc1"
itype = "t2.micro"
subnet = "subnet-e3f05dbc" # change this to your subnet id
publicip = true
keyname = "my-static-site-key-pair" #change this to your key name
secgroupname = "tf-my-ec2-sec-grp"
@akashdktyagi
akashdktyagi / gist:307b2eab61cad8e0a5781b33b7e5f4f6
Created December 10, 2023 07:20
Script to add to user data before creating AWS Ec 2 instance to install docker and nginx
# !/bin/bash
sudo yum update -y
sudo yum install -y docker
sudo service docker start
sudo usermod -aG docker ec2-user
sudo chkconfig docker on
sudo yum install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx
@akashdktyagi
akashdktyagi / gist:1ab6bf4983782109d06a85a38b524072
Created May 15, 2023 03:40
Run Selenium container in Dockerized Jenkins agent. Selenium mini grid
try {
networkId = UUID.randomUUID().toString()
sh "docker network create ${networkId}"
inner.call(networkId)
} finally {
sh "docker network rm ${networkId}"
}
}
pipeline {
@akashdktyagi
akashdktyagi / Java
Created May 15, 2023 03:37
Use of Selenium Dev Tools CDP to modify header of the request- add authorization token
URL gridUrl = new URL("url");
EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions.setPlatformName(String.valueOf(Platform.LINUX));
edgeOptions.addArguments("no-sandbox");
// EdgeDriver driver = new EdgeDriver(edgeOptions);
EdgeDriver driver = new EdgeDriver();
// RemoteWebDriver driver = new RemoteWebDriver(gridUrl);
DevTools devTools = driver.getDevTools();
devTools.createSession();
@akashdktyagi
akashdktyagi / gist:eddc87cbfb2de2bbf8448c032a285509
Created January 23, 2023 11:53
Run Side Card Container With in a Jenkins Pipeline
def withDockerNetwork(Closure inner) {
try {
networkId = UUID.randomUUID().toString()
sh "docker network create ${networkId}"
inner.call(networkId)
} finally {
sh "docker network rm ${networkId}"
}
}
@akashdktyagi
akashdktyagi / TestRunnerCucumber.java
Created April 12, 2021 13:15
Test Runner for Cucumber Automation
package runner;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions
( features="classpath:features",