Showing posts from 2020

azure devops multiple custom condition in yaml

In case you run into a situation whereby you need to specify multiple condition in your task / job, you can try the following command :-

condition: and(succeeded(), or(eq(variables['Build.Reason'], 'PullRequest'),  eq(variables['Build.SourceBranch'], 'refs/heads/master')))

git log to see only changes in your branch

If you want to see only changes in your current git branch, use the following command :-git log master..
Otherwise, to specify your target branch git log master..<your branch name>

Setting up containerized azure pipeline agents into Azure Devops

This is a tutorial for setting up build agents in Azure Devops. Lets say you would like to add more build agents, there's a couple of ways to do it. You can add vm scale set or you can use docker. This tutorial is about using microsoft pipeline agent image to add an agent to your Azure Devops pipeline build process. The setup is pretty easy, all you need is to generate your PAT token. You need to have AGENT READ-WRITE SCOPE. Run docker command sudo docker run \  -e VSTS_ACCOUNT=cdiwi \  -e VSTS_TOKEN=YOUR_PAT_TOKEN_WITH_AGENT_READWRITE \  -e VSTS_AGENT='jeremydev-agent' \  -e VSTS_WORK='/var/vsts/$VSTS_AGENT' \  -it you have your container running you should see the following outputs:- 

And if you go back to your Azure Devops pipeline and start looking for the agent name 'jeremydev-agent', you should be able to see something similar below :-

git command of the day - allow-unrelated-histories

This is a pretty handy command to blog about :)

git pull origin master --allow-unrelated-histories

Setting up jest for your node app that uses typescript :)

Here you go, proper instruction for setting up jest for your node app that uses typescript :)

moq automock sample code

Automock helps to reduce code tremendously. But it can be tricky to use at times.

Here are some simple code that you can get started with, to show it works. Sometimes those calls can get complicated and you need to know what works. The code sample below, is simple, straight forward and you won't have problem getting it to work

Enabling flake8 in vscode

In your .vscode directory, please update your settings.json file

{ "python.pythonPath": "/anaconda3/envs/myenv/bin/python", "python.linting.pylintEnabled": false, "python.linting.flake8Enabled": true, "python.linting.enabled": true }

install specific version of tensorflow

Unfortunately i have problem getting tensorflow installed on my ubuntu using pip. So i resorted to using system install and it works

pip3 install --user --upgrade tensorflow

Running microsoft deepspeed

If you wanna run Microsoft deepspeed using docker, then try with the following command :-

sudo docker run -it --entrypoint bash deepspeed/deepspeed:latest

setting up drozer

Installing server 

create python 2.7, and then create your environment. Then install using drozer server side using :-

pip install drozer-2.4.4-py2-none-any.whl

Start emulator 

./emulator avd Pixel_2_API_27
Install the agent using

adb install drozer-agent-2.3.4.apk
adb forward tcp:31415 tcp:31415

Please goto your android emulator and then run Drozer by firing up the application and then click on "Off" (to turn it on)

Next, run

 drozer console connect

Now, we are in. To list all the command please type


Some common command to use are :-


How to do something useful with it?

Trying to look for database for passwords

run scanner.provider.findurls

run app.provider.query content://

Following azure best practices and naming conventins

nuget commonly used command

nuget config -set http_proxy.password= nuget config -set http_proxy="http://@proxycompletename" nuget config -set http_proxy.user=""nuget sources add -name MyPackageSource -source -username username -password password

Maven separates repository between plugin and package repositories.

The following example illustrate how we can setup plugin and package repository. Maven tends to separate this out individually.

Setting up git to use Azure Devops over proxy

The following provide a configuration that you need to update when you're trying to use git over a proxy to hit into Azure DevOps.

[user] email = name = Jeremy.Woo password = mypassword [http ""] proxy = http://jeremywo:mypassword@myproxyserver:80 [credential] helper = store

Azure CMK for storage account

If we were to use key rotation in Azure storage account, then we can do it by setting up our Azure KeyVault and tying it to a storage account. The problem with this approach is that, it will be harder because right now, we're trying to manage key ourselves.

Typically this is an answer to 'how can i apply key rotation to Azure storage account'.

Azure Devops - how to build pipeline that uses npm securely for docker images

This is a setup for npm, docker images and react app (This doesn't matter i guess)

In this post, we are going to be building a secure pipeline. When we say secure, we mean

a) No PAT token is saved in source code or as a insecure variable. No credential is leak We also separate the pipeline and allow it to evolve independently.

b) No token is written into docker image. User wil not be able to use docker inspect  / docker history to obtain PAT token.

In a nutshell, we use Azure Devops and build machine to install npm packages. Then copy all the files, assets and node_modules into docker for next steps to build it.

I know some of you might say, we want a full containerized build. This is a good way too, if you think about it. you don't have to generate user .npmrc file and somehow maintain that in variable group. It just make the steps so much simpler.

This is the Azure Devops build pipeline setup

Let's look at the dockerfile setup

azure devops build pipeline template : using if macro

Did you know that you can actullly use template with abit of if macro magic as shown below :-

Create a local git for Azure WebApp deployment

From Azure portal, goto your webapp service and select deployment center.  Then create a local git.

It looks something like this :-

git remote add azure

To figure out the username and password, click on the Credential Tab. Then you can provide the username and password for writing to the git repository.

Remember to execute the command below to deploy :-

git push azure 

Azure function v1, v2 and v3 configuration

React-create script getting unrecognisable token when running yarn or nom start

This is most likely you are using a very old version of the tools (yarn / npm). Try to uninstall and then reinstall the yarn.

To uninstall,

npm uninstall yarn

To Install

brew install yarn

Then you should be able to use other form of tooling, like yarn install and yarn start to fire up your 'react-create-script'

Docker build with Maven over proxy

Getting maven to build over proxy can be tricky.  So here is an example of a proxy setup which might help. But still you need to ensure that your Maven setings.xml proxy configuration (name and password are correct)

Azure Devops - $(Build.SourcesDirectory) and (System.DefaultWorkingDirectory) is the same

Did you know that

$(Build.SourcesDirectory) and
(System.DefaultWorkingDirectory) has the same value. For example if you

$(Build.SourcesDirectory) is /home/buildadmin/agent/_work/97/s then
(System.DefaultWorkingDirectory) is /home/buildadmin/agent/_work/97/s then

In case, somebody ask, this could come in handy.

Docker to copy entire folder

To copy entire folder from a running docker instance, all you have to do is use the following command.

docker cp :/my/folder_name_only

docker run --name targetdockerapp --rm -d ${{ parameters.dockerRegistryName }}/${{ parameters.dockerRepositoryName }}:latest
docker cp targetdockerapp:app/target/site/jacoco $(System.DefaultWorkingDirectory)

React css module

Css module cannot have dashes, It should be something like a whole word.

Css format :-



Running dotnet restore for command line in a proxy server (corporate network)

Run dotnet restore and see what info you're getting.

If you're getting 407 (Proxy access denied)

nuget config -set http_proxy="http://proxysslbypass"
nuget config -set http_proxy.user="ourUserName"
nuget config -set http_proxy.password="Your secret password."

If you're getting 401 then

Download nuget.exe (

Then run the following command line, please make sure you replace the package url name and PAT Token info which you got from Azure DevOps.

nuget.exe sources Add -Name "Nuget_Artifact" -Source "" -username MY_USERNAME -password MY_PAT_TOKEN

CSS Grid - fixing first and second column. Third column gets the rest

you can use grid-template-column to fix the size of your grid column. For example, you might want to say 1st and 2nd column has the size of 100px and 200px respectively.

The rest goes to column 3, which takes on auto-fill, don't specify any grid size to it.

Terraform - Azure container registry multiple ip network rule setup

You can setup multiple ip rules using for container registry using the terraform code

Azure Devops - Container based build

Here is a sample of using container based build in Azure Devops

While this looks cool, i could have use Dockerfile to do similiar things. The only problem i have install docker. Using the containerized based built, I have to copy or manage my artifact directory.

Intellij : How to run maven goal

To run a specific maven goal, click on the "m" for Maven :) and then select the goal you would like to run. If you don't see your goal, just type it out as shown below :-

Specifiying goal as illustrated in diagram below :-

dockerfile - using image that allows some debugging for java build

Using this image for debugging purposes during docker build works! :)

FROM amd64/adoptopenjdk:13.0.2_8-jdk-openj9-0.18.0-bionic AS publish

react reducer what

Ok where is the general accepted implementation with react-redux. It is a global / subsection state management that maintain data used in your application. For example, lets say you have a Todo list, you might use, the following objects to keep track of it.

- TODO_ID - when user click on ADD_TODO
- TODO_LIST - keep tracks of all your tasks you have created.

These are all trigger based on actions. This is why we have to setup actions. Action when someone click "Add Task". Then it sends a certain message - "ADD_TODO' to be specific to a  reducer.

What is a reducer?
Say you have fire up / dispatch / send out a 'ADD_TODO' instruction and you increment current task id with 1. So you can have a unique Id or some way to keep track of it. This is where you pass it to a reducer. You say hey, my ADD_TODO is fired, get me a new TASK_ID.

Reducer is where you are allowed to changes / update state STATE - TODO_ID.

Some other action will update TODO_LIST and so …

azure naming convention

It just seems so clear to me that having "-" dash as a naming convention is bad and causes more problem. Azure container registry won't like it, storage acount won't like it and probably a few others. But you will never know ......... so it can causes more pain than anything else :(

react basics

Set state the correct way. Setstate is a merge operation.

React dumb component

Better way to work with events

Another const example,

Check out this cool useEffect()

installing debian package on ubuntu

If you're trying to install debian package on Ubuntu, all you need is the following command :-

sudo dpkg -i DEB_PACKAGE

Linux distro name - when uname don't tell you much

Try running the following command and that will help to display your Linux distro name.
This works for Redhat. :)

cat /proc/version

docker image running dotnet - A fatal error occurred, the folder [/usr/share/dotnet/host/fxr] does not contain any version-numbered child folders

This error seems to be Linux specific. When i ran it on Redhat it gives me this issue. Otherwise running it on Ubuntu Bionic, this problem doesn't shows up.

Azure Devops pipeline - Getting dotnet tools (customer command) to run

Often have problem when there is more than a feed config in your nuget.config. For example, having your private feed, dotnet custom tool like "dotnet tool install' just won't work.

To resolve this you specify a --configfile and provide a single config file entry called dotnettool.config which has the content below :-

  - task: DotNetCoreCLI@2 displayName: Install ReportGenerator tool inputs: command: custom custom: tool arguments: install --tool-path . dotnet-reportgenerator-globaltool  --configfile dotnettool.config feedsToUse: 'select'
dotnettool.config content

xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <clear/> <addkey=""value=""/> </packageSources> </configuration>

salesforce - working with records

This setup uses a controller that contains the following code, please note that this code is available in /default/classes/bearController.cls


Notice how different the import path is :-

import getAllBears from '@salesforce/apex/BearController.getAllBears';

And load bead runs this method to run query and assigned it into a variable bear with a @track decorator

loadBears(){getAllBears().then(result =>{this.bears = result;}).catch

salesforce - getting all the objects

To query all salesforce object name, you can use the following soql -

salesforce parent child event interfactions

In the lightning-button-icon, we have a onclick event which can be used to fire off events -

And code below fires off an event called 'bearview'

On the parents side of things, we need to tell parent component to handle the event,

On the parent's javascript :-

salesforce - getting started - common terms

@track - is a decorate that make a variable  automatically refresh when its value changes

Handing UI events

On the javascript side of things

Bear tile component

This sections allow us to create a new custom component that is used in a parent component.

Lets say we are creating a component called beartile. Here is the javascript side of things :-

The html :-

Looking at the parent html :-

Also noticed that, it become c_bear_tile - where c is the default, somewhat predefined name for components and then as the upper case changes, then an underscore is introduced.

Loading style :-

REST API Http versioning

Common ways to go about it would be :-

1. URL versioning

An example would be :-

2. Query string versioning

3.Header versioning

GET HTTP/1.1 Custom-Header: api-version=1

4. Media type versioning - this is more for client trying to digest the media type data content. For example, the data content supported by the client should be of pdf version 2.

GET HTTP/1.1 Accept: application/vnd.adventure-works.v2+pdf

Recap in HTTP design

Some of the common stuff when it comes to responding to REST based API are as follows :-

1. GET - 200 for OK, 404 when not found

2. POST - 201 for created and 204 No update. Returns 404 if it is a bad request. Returns 409 when conflict.

For long running or async processes, an API could just return 202 (ACCEPTED) with a link to poll status info. Agent can poll the status and once upon completed returns 303.
Results can be show here :-

HTTP/1.1 202 Accepted Location: /api/status/12345

HTTP/1.1 303 See Other Location: /api/orders/12345

3. PUT - 201 for created and 204 No update. Returns 409 when conflict.

4. PATCH - this is mainly used for update resource. It will return 415 for unsupported media, 400 bad request and 409 for conflict.

5. HEAD - for handling large content

If you have a long running task or wanted to poll status of a resources, then you can do something like this :-

POST to a resource and returns 202 (Accepted) with a location of resource URL. 

Issue GET on the new location r…

salesforce lightning web component library

This is a link to salesforce component library that is essential for testing purposes.

Web lightning component documentation site

Using Powershell for Azure Devops to refer to predefined variables.

Using Powershell for Azure Devops Linux agent to refer to variables can be hard to get right essentially just use $(build.SourceBranchName) - the build.SourceBranchName is what listed in the documentation.

You can see one example given below :-

- task: PowerShell@2 displayName: 'PowerShell contruct VersionSuffix if not Master' inputs: targetType: 'inline' script: |          Write-Host "Setting up version info"          $VersionSuffix =  'prerelease' + '.$(build.SourceBranchName).' + $(build.buildid)          write-host "##vso[task.setvariable variable=VersionSuffix]$VersionSuffix"          Write-Output "##vso[build.updatebuildnumber]$($env:VersionPrefix)-$VersionSuffix"
failOnStderr: true condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/master'))

using terraform expression

Terraform expression consist of conditional operators like ==, != and functions that you can leverage to work with input values. For example, lets say you want to concatenate two variable together, you can do that using terraform.

There are a whole lot of functions available which are categorized under string, numeric and collection functions.

Lets have a look at where you can use these functions. Functions are typically classified as expresssion and you can use it within a terraform code.


Let's have a look at the example below :-

In this example, i am combining a couple of function together (chaining) and produce a list as the final output. This snippet shows where we can :-

Disecting the code out further, we have substr functions, which attempts to get a subsection of a string except the last character.

substr(data.azurerm_storage_account.paymentmonitorui.primary_web_endpoint, 0, length (data.azurerm_storage_account.paymentmonitorui.primary_web_endpoint) -1)

Then we have c…

Salesforce codepen / playground

This let you get a feel of the codepen or playground for salesforce

mulesoft java invoke

To create a flow using java invoke. Please have a look at the flow below :-

As you can see, we need a java new component, then follow by a java invoke component.

Here is our java code :-

public class Greeter {

   public String Hello(String name) {
   return "Hello " + name;

Java new component requires the following configuration :-

And the java invoke component. As you can see we reference our variable using #[vars.mygreeter] :-

Note the class and method configuration below is very important.

mulesoft media type supported by dataweave

Ever wonder what type of media type supported by data weave?

application/avro Avro application/csv CSV application/dw DataWeave (weave) (for testing a DataWeave expression) application/flatfile Flat FileCobol CopybookFixed Width application/java JavaEnum Custom Type (for Java) application/json JSON application/octet-stream Octet Stream (for binaries) application/yaml YAML application/xml XMLCData Custom Type (for XML) application/x-ndjson

terraform refresh - what in the world ...

Terraform refresh sync state files with the real world. It does not affect resources but it will update state files.

setting up telegraf as a linux daemon

Installing telegraf on target server
curl --output telegraf.tar.gz -k
Placing telegraf executable in a specific folder.
tar xf telegraf.tar.gz

After extracting our telegraf.deb, you can move the binary to /usr/local/bin folder and configuration file to /user/local/etc/telegraf/telegraf.conf
Assuming we are in your expand tar directory, /telegraf/usr/bin
sudo cp telegraf /usr/local/bin
Assuming we are in your expand tar directory, /telegraf/etc/telegraf
sudo mkdir /usr/local/etc/telegraf
sudo cp telegraf.conf/usr/local/etc/telegraf
Next we need to specify what metrics we would like telegraf to send over.Example below shows the key configuration for DEV environment that we are interested in. The first is target database and server dns. Here we setup our hostname "urls = "" and database is called "dev_docker_telegraf".
# Configurati…