Skip to content

Instantly share code, notes, and snippets.

View priyanshus's full-sized avatar
🎯
Focusing

Priyanshu Shekhar priyanshus

🎯
Focusing
View GitHub Profile
@priyanshus
priyanshus / ConfigurableSimulation.scala
Last active January 5, 2021 07:33
Gatling Request Body Processor Use Case
package simulation
import io.gatling.core.Predef.Simulation
import io.gatling.core.body.{Body, ByteArrayBody, CompositeByteArrayBody, InputStreamBody, PebbleBody, RawFileBody, ResourceAndCachedBytes, StringBody}
import io.gatling.core.config.GatlingConfiguration
abstract class ConfigurableSimulation extends Simulation {
def processPayload(implicit configuration: GatlingConfiguration) : Body => StringBody =
(body: Body) => {
@priyanshus
priyanshus / kafka-consumer-for-partion.java
Created December 15, 2020 14:07
Kafka Consumer For Partitions
List<String> consumer(String topic) {
List<String> events = new ArrayList<>();
List<PartitionInfo> partitionInfos = null;
List<TopicPartition> partitions = new ArrayList<>();
partitionInfos = consumer.partitionsFor(topic);
if (partitionInfos != null) {
for (PartitionInfo partition : partitionInfos)
partitions.add(new TopicPartition(partition.topic(),
partition.partition()));
task uberJar(type: Jar) {
manifest {
attributes 'Main-Class': 'main.RunTest'
}
dependsOn configurations.runtimeClasspath
from sourceSets.main.output
from sourceSets.test.output
from sourceSets.main.resources
from sourceSets.test.resources
from {
public static void recursiveNode(JsonNode node) {
Iterator<Map.Entry<String, JsonNode>> it = node.fields();
if (node.isTextual() & node.toString().contains("sample")) {
System.out.println(node.toString());
}
while (it.hasNext()) {
JsonNode temp = it.next().getValue();
recursiveNode(temp);
class Calculator {
private var a = 0
private var b = 0
fun printResult() {
println(a + b)
}
fun firstNumber(a: Int) {
this.a = a
@priyanshus
priyanshus / port-scan.sh
Last active December 26, 2023 10:12
NMAP scan for a list of subdomains
#!/bin/bash
#Performs port scan using nmap
print_usage() {
cat << _EOF_
Utility to scan open ports. Can be used to scan ports for a domain or a list of domains specified in a file.
Example Usage:
-h, --help Show brief help
-d, --domain Domain name or ip to scan
-f, --file Spefify a file containing domains/IPs to scan
@priyanshus
priyanshus / active-directory.ps1
Created February 15, 2019 05:19
Active Directory Script to Add Group and Users
foreach ($i in 1..50) {$create_group = New-ADGroup -Name Group+$i -GroupCategory Security -groupScope Global -Path "OU=<myOU>,DC=<myDC>,DC=<myDC>"}
foreach ($i in 1..100) {$create_user = New-ADUser -Name ("User" +$i+ " Test") -GivenName ("User" + $i) -Surname Test -AccountPassword (ConvertTo-SecureString -AsPlainText "<password>" -Force) -Path "OU=<myOU>,DC=<myDC>,DC=<myDC>" -PassThru | Enable-ADAccount}
foreach($i in 1..50) {Add-ADGroupMember -Identity ("Group-" + $i) -Members ("User" + $i)}
foreach ($i in 1..10) {$create_user = New-ADUser -Name ("user" +$i+ " Test") -GivenName ("user" + $i) -Surname Test -AccountPassword (ConvertTo-SecureString -AsPlainText "<password>" -Force) -PasswordNeverExpires $true -EmailAddress ("user" + $i+ "@test.local") -MobilePhone ($i+234) -Path "OU=<myOU>,DC=<myDC>,DC=<myDC>" -PassThru | Enable-ADAccount}
@priyanshus
priyanshus / Wait.java
Created September 4, 2015 07:07
Wait until angular finishes $http calls in Selenium webdriver
/**
* Sometime it happens while automating the angular app, view gets loaded entirely but performing any action
* on that view fails the test. This could happen because angular $http calls are still pending in backend.
* We can have explicit wait in this way to ensure that angular has made all the $http calls.
* Wait until angular finishes the $http calls while loading the view
*/
public void waitForAngular() {
final String javaScriptToLoadAngular =
"var injector = window.angular.element('body').injector();" +
"var $http = injector.get('$http');" +