Skip to content

Instantly share code, notes, and snippets.

@sureshnath
sureshnath / sample.groovy
Last active October 27, 2020 20:00
using groovy playground
import groovy.json.JsonSlurper
def jsonSlurper = new JsonSlurper()
def object = jsonSlurper.parseText(
'{"count":20,"teams":[{"id":322,"name":"Hull City FC","shortName":"Hull","squadMarketValue":null,"crestUrl":"http://upload.wikimedia.org/wikipedia/de/a/a9/Hull_City_AFC.svg"},{"id":338,"name":"Leicester City FC","shortName":"Foxes","squadMarketValue":null,"crestUrl":"http://upload.wikimedia.org/wikipedia/en/6/63/Leicester02.png"},{"id":340,"name":"Southampton FC","shortName":"Southampton","squadMarketValue":null,"crestUrl":"http://upload.wikimedia.org/wikipedia/de/c/c9/FC_Southampton.svg"}]}'
)
def allTeamNames = object.teams.name
def namesWithCity = object.teams.findAll {it.name =~ /City/}.name
@sureshnath
sureshnath / git.txt
Last active June 9, 2020 17:08
git useful commands
# to see commit logs with short commit hash
git log --pretty=reference
# to pick and squash multiple commits
git rebase --interactive [commit-hash]
# nice explanation available in https://www.internalpointers.com/post/squash-commits-into-one-git
# sparse checkout set root .gitignore and followed but any folder seperated by space
git sparse-checkout set //.gitignore
@sureshnath
sureshnath / postman-logging-with-level.js
Created May 1, 2019 10:29
postman-logging-with-level
// console-log-level@1.4.1 - start
var util = require('util')
var levels = ['trace', 'debug', 'info', 'warn', 'error', 'fatal']
var noop = function () {}
var getLogger = function (opts) {
opts = opts || {}
opts.level = opts.level || 'info'
var logger = {}
@sureshnath
sureshnath / mojo.help.txt
Created March 17, 2019 15:35
MoJo command line
https://stackoverflow.com/questions/31620967/any-way-to-specify-a-fileset-as-command-line-parameter
@sureshnath
sureshnath / postman-bigint.js
Created January 22, 2019 17:10 — forked from mahasak/postman-bigint.js
Postman Test Runner BigInt fix
var BigNumber,
isNumeric = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,
mathceil = Math.ceil,
mathfloor = Math.floor,
notBool = ' not a boolean or binary digit',
roundingMode = 'rounding mode',
tooManyDigits = 'number type has more than 15 significant digits',
ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_',
BASE = 1e14,
LOG_BASE = 14,
@sureshnath
sureshnath / txt
Created June 29, 2018 15:48
cucumber step tips
public void step_method(String arg1, DataTable arg2) throws Throwable {
// Write code here that turns the phrase above into concrete actions
// For automatic transformation, change DataTable to one of
// List<YourType>, List<List<E>>, List<Map<K,V>> or Map<K,V>.
// E,K,V must be a scalar (String, Integer, Date, enum etc)
}
pass other steps as parameter to constructor of step class
@sureshnath
sureshnath / xpath-sel-table.txt
Created January 27, 2018 01:49
XPath select column1 where column2 = value2 and column3 = value3
//table/tbody/tr[
td[count(//table/thead/tr[1]/th[.="column2"]/preceding-sibling::th)+1]/./a[contains(text(),"value2")]
and
td[count(//table/thead/tr[1]/th[.="column3"]/preceding-sibling::th)+1]/./a[contains(text(),"value3")]
]
/td[count(//table/thead/tr[1]/th[.="column1"]/preceding-sibling::th)+1]
@sureshnath
sureshnath / grep.txt
Last active August 29, 2015 14:27
grep useful options
-P - perl type regex syntax
-A -B - context lines
--- very useful
http://askubuntu.com/questions/53071/how-to-grep-for-tabs-without-using-literal-tabs-and-why-does-t-not-work
@sureshnath
sureshnath / excel-command-expansion.txt
Created April 22, 2015 13:09
excel command expansation f9(windows) or cmd+=(mac)
excel command expansation f9(windows) or cmd+=(mac)
http://www.get-digital-help.com/2011/02/09/concatenate-a-cell-range-without-vba-in-excel/
@sureshnath
sureshnath / regex.email.txt
Created April 10, 2015 09:48
email regex
[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}\b
https://regex101.com/
/[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}\b/
[A-Za-z0-9._%-]+ match a single character present in the list below
Quantifier: + Between one and unlimited times, as many times as possible, giving back as needed [greedy]
A-Z a single character in the range between A and Z (case sensitive)
a-z a single character in the range between a and z (case sensitive)
0-9 a single character in the range between 0 and 9