Skip to content

Instantly share code, notes, and snippets.

saurabh-sp-tripathi

Block or report user

Report or block saurabh-sp-tripathi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@saurabh-sp-tripathi
saurabh-sp-tripathi / groovy-how-to-get-all-methods.md
Created Jul 11, 2019
quick copy paste for jenkins script console
View groovy-how-to-get-all-methods.md
def methods = obj.getClass().methods.collect { it.name }
println methods.each {println it}

//courtesy: my week memory, lazyness and https://stackoverflow.com/questions/22065290/how-to-get-all-method-names-of-a-class-without-inherited-methods-with-groovy
@saurabh-sp-tripathi
saurabh-sp-tripathi / when_singleton_could_be_bad_4_even_stateless_object.md
Last active Aug 15, 2018
A use case where singleton can be bad even for the stateless object
View when_singleton_could_be_bad_4_even_stateless_object.md

While working on TestAutomation, we introduced spring IoC and had a look at PageObjects, there are totally stateless so why dont' let just make 'em singleton?

IMO it will burden unecessary memory requirements on JVM, but given today's machine where we usaually have many GB of RAM I am not sure how significant can be the impact.

Let's say we have 100 pageObjects, if 20 instance create a load of 1 MB, 100 will create 5 MB.

If you are using singleton for before the test spring has to load the 10MB, although it will be one time cost due to context-caching

@saurabh-sp-tripathi
saurabh-sp-tripathi / why_prefer_non_static.md
Last active Aug 15, 2018
this is in progress note on why prefer non static method over static
View why_prefer_non_static.md

As I said I would always prefer non-static over static method.

  • I am big fan of pure/stateless function,there easy to understand and test, Static method as pure function i.e stateless are not bad but the real problem is to maintain the decipline to keep the 'em stateless.
  • Testablitly: Class B has static method B.foo(), now consider
class A  {

	public void bar() {
		//some important code
		B.foo();// How mock foo bahaviour? may be fiddling classloader with PowerMock but that comes with some bagage too
		//some more important code
@saurabh-sp-tripathi
saurabh-sp-tripathi / ParamSetListBuilder.java
Created Aug 14, 2018
a temp gist, this code is used in testng to create combination of parameter in dataProvider
View ParamSetListBuilder.java
public static class ParamSetListBuilder {
private List<List> paramList = new ArrayList<>();
private Logger logger = LoggerFactory.getLogger(getClass());
public ParamSetListBuilder addParams(List paramListToCombine) {
addParamsAtIndex(paramListToCombine, Helper.calcParamIndex(paramList));
return this;
}
View regexp.md

match anything : .* eg: regex \(.*\) matches (a, b, c, d) or (a..dlldkfjdlkjaoi) or (9788E98e7r8e((&^&*^&)

  • find & replace
PaymentByCard.nameOfBrowser.equalsIgnoreCase\(("[a-z]*")\)
$1.equalsIgnoreCase(browserName)
==> "chrome".equalsIgnoreCase(browserName)

View vim.md
  • file{begin,end}  : `gg, G`
    
  •  line{begin, end} : `0, $`
    
  •               Undo: `u`
    
  •  Select,copy,paste: `Vyp` (weep) 
    
  •  Select,cut,paste: `Vdp` (we dip)
    
  •  show line number : `:set number` ; hid : `set nonumber`
    
  • move cursor previous pos: ``

#File explorer

  • :set wildmenu >> :set path+=** >> :find <tab>
View emacs.md
  • cancel action : C-g
  • query/replace in selected : C-<space> select region >>> M-x >> replace-string >> ....
  • copy/cut paste : M-w/C-w C-y
  • del i.e kill line: M-x
  • list bufferes : C-x C-b ; close it : C-x 1
  • Switch buffers : C-x b or select from C-x C-f
  • Save all buffer : C-x s this will ask you for all unsaved buffer
  • File ops [todo: anything from below if repeated above, delete the above one]
	C-x C-f		Find file
@saurabh-sp-tripathi
saurabh-sp-tripathi / intellij-cmd.md
Last active Aug 2, 2018
Intellij shortcut keys
View intellij-cmd.md
  • Search action/command : ctrl + shift + a
  • switch vim : alt + T => ctrl + alt + v
  • methods : ctrl+F12
  • goto line : ctrl + g
  • select and paste recent clipboard: ctrl+shift+v
  • back and forth curson ctrl + alt + <- or ->

Fresh set up

View jenkins.md

Set build number of a job: Jenkins.instance.getItemByFullName("YourJobName").updateNextBuildNumber(45)

@saurabh-sp-tripathi
saurabh-sp-tripathi / git-cmd.md
Last active Jul 24, 2018
This gist contains list of reference of git commands or workflows
View git-cmd.md
  • list branches (local i.e tracking and remote): git branch -vv
  • checkout: git checkout --track origin/abranch
  • Create remote branch
    //Create a new branch:
    git checkout -b feature_branch_name
    //Edit, add and commit your files. Push your branch to the remote repository:
    git push -u origin feature_branch_name
You can’t perform that action at this time.