Skip to content

Instantly share code, notes, and snippets.

View aksinghdce's full-sized avatar

Amit Kumar Singh aksinghdce

View GitHub Profile
@aksinghdce
aksinghdce / gist:cbd04da524b89e3ceedb57cc9cc7da83
Last active August 29, 2019 17:06
input templated XML file and replace the placeholders with random strings of specific length
import groovy.text.GStringTemplateEngine
def engine = new GStringTemplateEngine()
def pool = ['a'..'z','A'..'Z',0..9,'_'].flatten()
Random rand = new Random(System.currentTimeMillis())
def orderidChars = (0..10).collect { pool[rand.nextInt(pool.size())] }
def order_id = orderidChars.join()
vars.put("order_id", "T_"+order_id)
@aksinghdce
aksinghdce / read_txt_into_http_sampler.groovy
Last active August 29, 2019 17:04
Read excel data to parameterize Jmeter Sampler
/*
Problem Statement:
Based on variable URL patterns extract parameters into Jmeter variables for use by Samplers that would execute later on.
*/
// Get the input data populated
//Type 1: ${host}/api/c/<unified-id>/_/N-<nvalue>
//Type 2: ${host}/api/c/<unified-id>/_/N-<nvalue>
//Type 3: ${host}/api/c/<unified-id>/_/N-<nvalue>?Ns=<sortParam> {The code for this one is not present
@aksinghdce
aksinghdce / multi_level_columns_dataframe.py
Created November 28, 2019 17:03
Create Pandas DataFrame with multi-level columns
columns = [("term", "word"), ("term", "phrase"), ("context", "academic"), ("context", "non-academic"), ("meaning", "short"), ("meaning", "long")]
df = pd.DataFrame(columns=columns)
df.columns = pd.MultiIndex.from_tuples(columns)
# To set values
df.loc[0, ("term", "word")] = "condescension"
@aksinghdce
aksinghdce / query-pandas-dataframe-for-substring-in-column.py
Last active August 5, 2022 21:31
Query Pandas DF for substring in column
df[df['A'].str.contains("hello")]
@aksinghdce
aksinghdce / move_elasticsearch_documents_based_on_time
Created January 4, 2020 08:41
from source elasticsearch to AWS elasticsearch move documents
from elasticsearch import Elasticsearch
from elasticsearch import helpers
import json
# Define config
port = 9200
timeout = 5000
index = "jmeter"
doc_type = "type"
size = 10000
@aksinghdce
aksinghdce / process_killer
Created January 31, 2020 17:16
Kill a long list of processes
# Works in a linux environment
ps -ef | grep -i jupyter | awk '{print $2}' | xargs kill -9
@aksinghdce
aksinghdce / ElasticSearch_SQL
Last active January 31, 2020 22:01
Run SQL like query on ElasticSearch
import requests
import json
import numpy as np
import pandas as pd
url = 'http://<ElasticSearch_IP_Address>:9200/_sql?format=csv'
headers = {
'Content-Type': 'application/json',
}
query = {
@aksinghdce
aksinghdce / gist:9d0e92cb7b7f9d7d538f6fc10957e12a
Created April 24, 2020 17:53
Grep for pattern in one line file
grep -E -o ".{0,10}pattern.{0,10}" content.txt
@aksinghdce
aksinghdce / large_file_identify
Last active August 21, 2022 03:09
Identify large files in unix directory
du -h * | awk '{print $1 " " $2}' | grep -E "[0-9]+[.]?[0-9]*M"
@aksinghdce
aksinghdce / git add all modified files
Created June 24, 2020 17:34
git add large list of modified files
git add `git status | grep "modified:" | awk '{print $2}'`