Skip to content

Instantly share code, notes, and snippets.

@aimtiaz11
aimtiaz11 / keep_putty_alive.md
Last active September 6, 2023 11:26
Linux: Keeping Putty Session Alive

Linux: Keeping Putty Session Alive

Set to alias or copy paste to terminal to keep session alive.

while true; do echo "hello" > /dev/null; sleep 25; done
@aimtiaz11
aimtiaz11 / timer-vars.md
Last active August 2, 2024 01:13
Adding Timer Variables in Mule Flows

Adding Timer Variables in Mule Flows

Adding timer variables in Mule flows to check for performance bottlenecks.

Setting Timer Variable set-variable

<set-variable value="#[%dw 2.0 import currentMilliseconds from dw::util::Timer --- currentMilliseconds()]" 
              variableName="http_before" doc:name="http_before" mimeType="application/java"/>
@aimtiaz11
aimtiaz11 / readme.md
Created October 19, 2022 06:14
Multiple Payload Validation Error using Mule 4 Dataweave
@aimtiaz11
aimtiaz11 / readme.md
Last active October 14, 2022 14:20
Making Munit work in Studio 7 (Mule 4)

Making Munit work in Studio 7 (Mule 4)

If you are having trouble running Munit in Anypoint Studio, try updating your Studio version and application's munit dependencies to latest versions.

After doing updating to below updates, I could run & debug Munit tests in my Anypoint Studio.

Prior to that, I was getting all kind of weird internal errors.

My Setup (as of 14th October 2022):

@aimtiaz11
aimtiaz11 / munit-sample.xml
Created October 12, 2022 06:37
Munit Set Event (Payload and Query Params)
<munit:execution>
<munit:set-event doc:name="Set Event - Payload and Query Params">
<munit:payload value="#[MunitTools::getResourceAsString('some-api/api-request.json')]" mediaType="application/json" />
<munit:attributes value='#[
{
"queryParams": {
"doc_type": "abcd"
},
"uriParams": {
@aimtiaz11
aimtiaz11 / readme.md
Last active September 21, 2022 02:37
Anypoint - Listing apps deployed in Environment

Anypoint - Listing apps deployed in Environment

The APIs to list appliations deployed to an environment in Mulesoft depends on the type of application - Cloudhub, On-prem, or RTF.

CloudHub

Cloudhub APIs

On-Prem

Use the Anypoint Runtime Manager or ARM APIs

@aimtiaz11
aimtiaz11 / readme.md
Created September 8, 2022 01:20
Windows - find & kill processes occupying port

Windows - Find & Kill processes occupying port

Find the process

netstat -a -n -0 | find "8081"

Note down the value in last column which is the PID.

Get Process Details

Get-Process | Where-Object {$_.Id -eq 16820}
@aimtiaz11
aimtiaz11 / bash-reference.md
Last active January 16, 2023 23:43
Bash Reference - If-statements

Bash Reference - If-statements

Arithmatic Operation

Wrap expression in the if-statement with (( expression));

STRING_COUNT=$(grep -c 'hello world' path/to/file.txt)
echo "String count: $STRING_COUNT"

if (($STRING_COUNT == 1 )); then
 sed -i 's/hello world/hello mars/' path/to/file.txt
@aimtiaz11
aimtiaz11 / get-token.ps1
Created July 26, 2022 03:22
Get OAuth Token from Anypoint via Connected App (PowerShelll)
$ClientId = "<enter connect app client id>"
$ClientSecret = "<enter connect app client secret>"
## Step 1: Login to get Token
$Props = @{
Uri = "https://anypoint.mulesoft.com/accounts/api/v2/oauth2/token"
Method = "POST"
Headers = @{
@aimtiaz11
aimtiaz11 / validate-branch.yml
Created March 20, 2022 12:13
Azure DevOps - Validate that build branch is not behind master
steps:
- task: PowerShell@2
displayName: Validate - Build branch is not behind master
condition: or(eq(variables['Build.SourceBranchName'], 'develop'),startsWith(variables['Build.SourceBranchName'], 'release-'),startsWith(variables['Build.SourceBranchName'], 'bugfix-'),startsWith(variables['Build.SourceBranchName'], 'hotfix-'))
inputs:
targetType: 'inline'
failOnStderr: true
script: |
$Uri = "$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_apis/git/repositories/$(Build.Repository.ID)/stats/branches?name=$(Build.SourceBranchName)&api-version=6.0"