Skip to content

Instantly share code, notes, and snippets.

View mashariqk's full-sized avatar
🎯
Focusing

Mashariq Khan mashariqk

🎯
Focusing
  • 08:06 (UTC -05:00)
View GitHub Profile

Keybase proof

I hereby claim:

  • I am mashariqk on github.
  • I am mashariqk (https://keybase.io/mashariqk) on keybase.
  • I have a public key whose fingerprint is 06EB 5B8C E6F5 BFD5 5052 85AF CF94 1610 8819 168A

To claim this, I am signing this object:

@mashariqk
mashariqk / SynonymCSVToImpex.py
Created June 12, 2018 14:59
Takes in a CSV and converts into an impex for all the indices mentioned in the indexNames list object
fileName = "CsvFile.csv"
indexNames = ["indexName1", "indexName2"]
for indexName in indexNames:
with open(fileName, "r") as sourceFile:
with open(indexName + ".impex", "a") as targetFile:
targetFile.write(
"INSERT SolrSynonymConfig;facetSearchConfig(name);language(isocode)[allownull=true];synonymFrom[allownull=true];synonymTo\n")
for line in sourceFile:
listOfFields = [x.strip() for x in line.split(",")]
@mashariqk
mashariqk / executeCurlLoop.py
Last active June 6, 2018 18:16
Clear cache of hybris in an infinite loop
'''
This script can be used to clear cache of a hybris instance in an infinite loop
'''
import os
import time
#The token and jsessionid can be fetched when clearing cache from HAC and checking the request header
xcsrf = "23-24-234-234-23"
jsessionid = "234234234234234"
@mashariqk
mashariqk / UpdateCustomerFile.py
Created June 5, 2018 16:28
Remove runtime logic and modify existing file
fileName = '../200k/Customer_06052018_1700.csv'
destFileName = '../200k/Customer_06052018_1799.csv'
with open(fileName,"r") as sourceFile:
with open(destFileName, "a") as targetFile:
for line in sourceFile:
listOfFields = [x.strip() for x in line.split(",")]
replacementForUid = '"' + listOfFields[3].replace('"','') + '|fl"'
listOfFields[3] = replacementForUid
@mashariqk
mashariqk / generateCustomerFiles.py
Created May 24, 2018 16:08
Script to generate a couple of big files for load testing
'''
This script will be used to generate mock Customer files to be loaded in non-PROD environment as part of load testing
'''
# First we will declare the constants that will be required
___doubleQuote = '"'
___comma = ','
INIT_SEED_VAL = '239480232'
RANDOM_SEED = int(INIT_SEED_VAL)
@mashariqk
mashariqk / splitFile.py
Created May 17, 2018 14:51
This script will take in one big file and split it into multiple files as controlled by the noOfFiles variable
'''
This script will take in one big file and split it into multiple files as controlled by the noOfFiles variable
'''
from itertools import (takewhile, repeat, islice)
fileName = 'mybigfile.txt'
noOfFiles = 5
targetFilePrefix = 'sample_'
targetFileEnding = '.txt'
@mashariqk
mashariqk / CheckSpecialCharsInFile.py
Created May 11, 2018 01:04
Script to check for special characters in a file
import re
filePath = '/Users/u/filewithspecialcharacters.csv'
fileEncoding = 'iso-8859-1'
pattern = r"^[a-zA-Z0-9_;:!@?'.#(){}*|~/+%&<>,–`=\"\s\-\$\[\]\^\\]*$"
compiledPattern = re.compile(pattern)
count = 0
@mashariqk
mashariqk / Excel2Impex.py
Created April 3, 2018 16:30
Simple python script to parse an excel file and output into an hybris impex
import xlrd
import pandas
df = pandas.read_excel('/path/to/Excel/File/ExcelFile.xlsx',sheet_name=0)
with open("excel.impex", "a") as impexFile:
impexFile.write("UPDATE CUSTOMER[batchmode=true];originalUid[unique=true];field1;field2(code);field3[dateformat=MMM dd yyyy hh:mm aa]")
for index, row in df.iterrows():
if isinstance(row['excel_field3_name'],str):
@mashariqk
mashariqk / postmanHelper.js
Created February 26, 2018 19:14
This function will replace all environmental variables in the request with their values.
function returnParsedUrl() {
var url = request.url.trim();
var firstArray = url.split('{{');
var listOfProperties = [""];
for (i = 1; i < firstArray.length; i++) {
listOfProperties[i - 1] = firstArray[i].substring(0, firstArray[i].indexOf("}}"));
}
var completeUrl = "";
for (i = 0; i < firstArray.length; i++) {
if (firstArray[i].includes("}}")) {
@mashariqk
mashariqk / mergeExcel.java
Created April 4, 2016 19:39 — forked from jsianes/mergeExcel.java
A Java application using Apache POI library for merging Excel files
import java.io.*;
import java.util.Map;
import java.util.Vector;
import java.util.HashMap;
import java.util.StringTokenizer;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;