Posts

Smart search / replace with regular expression and back reference

As a developer, I had to search and replace in my source code within single file or whole project. Occasionally the search and replace could involve regular expression and back reference to groups found in regular expression. For example: I need to replace equalTo("value 1234") to "value 1234" equalTo("value 5678") to "value 5678" These smart search and replace needs regular expression and back reference to the group. The following is an example to perform it through IDE like IntelliJ IDEA or Microsoft Visual Studio Code (VS Code) Search Reg Ex: equalTo\("(.*)"\) Replace Reg Ex: "$1" The same can be performed using sed as shown below For single file: sed -i '' -E 's/equalTo\("(.*)"\)/"\1"/g' some_file.txt For multiple files using find and xargs: find . -name "some_file*.txt" -print0 | xargs -0 -I {} sed -i '' -E 's/equalTo\("(.*)"\)/...

Mac OS Keyboard shortcuts for developers

As a developer, when I switched from Windows & Ubuntu OS to Mac OS, I struggled a lot to discover the shortcuts. The shortcuts are not very obvious as in Windows or Ubuntu. Hence I have compiled a list of shortcuts which I found very handy in Mac OS. General: Cmd + Space -> Spotlight search. Search/Open any app or files Cmd + Up Arrow -> Home key / Move to the start of the file Cmd + Down Arrow -> End key / Move to the end of the file Cmd + Left Arrow -> Go to start of current line Cmd + Right Arrow -> Go to end of current line Cmd + W -> Close current window or tab Cmd + Q -> Quit or close the application Cmd + Option + W -> Close all windows Cmd + M -> Minimise current window to the dock Cmd + H -> Minimise current window Cmd + Option + H -> Minimise all other application's windows Cmd + Tab -> Toggle between different applications Cmd + ` -> Toggle between windows in same application Cmd + Alt + D -> Show or Hide Do...

Bash Script Loops and Conditional statement examples

loops.sh conditionals.sh Sourcing functions in bash script

Bash Script Example

calculate.sh

Practical rsync command and options

Blazemeter Taurus load testing and offline jmeter html report

Recently I had used Blazemeter Taurus for load testing my application and I was quiet impressed with the features offered by Taurus. It is not a new tool by itself, instead it makes use of existing load testing tools like Apache JMeter or Gatling. However it offers enough abstraction to users from the underlying load testing tool using YAML configuration files. Advantages of using Taurus over JMeter 1) JMeter uses single jmx xml file to simulate the load test, which makes it hard for more than one person to work on the single jmx file and resolving conflicts might turn tricky 2) Easy to review changes made to the Taurus YAML file on commit by commit basis to understand the changes made to the load testing. This is especially handy during pull request process 3) Easy to run in non-interactive command line mode, so easy to integrate with CI tools 4) Official docker image provided by Blazemeter Taurus, which required minimal setup to run load test in development machines and also ...

JSON with curl and jq

This blog post captures some quick commands to deal with JSON from servers (Http APIs) using curl and jq command line tools About Jq: https://stedolan.github.io/jq/ Install jq: Mac: brew install jq Ubuntu or Debian: sudo apt-get install jq Sample JSON content: Assume the following JSON content will be returned from  URL http://api.example.com/some-json-content {     "user_name": "User 123",     "some_other_field": {         "sub_field": "sub_value"     },     "array_field": [         {             "field1": "value1",             "field2": "value2"         },         {             "field1": "value3",             "field2": "value4"         }     ] } UR...