Posts

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 :) https://basarat.gitbook.io/typescript/intro-1/jest

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 :- https://github.com/mwrlabs/drozer/releases/download/2.4.4/drozer-2.4.4-py2-none-any.whl 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 "ls" Some common command to use are :- app.package.attacksurface How to do something useful with it? Trying to look for database for passwords run scanner.provider.findurls com.android.chrome.browser run app.provider.query content://com.google.settings/partner

Following azure best practices and naming conventins

Following azur best practices and naming conventins https://docs.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/naming-and-tagging

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 https://pkgs.dev.azure.com/company/nuget/v3/index.json -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  = jeremy.woo@mysuper.com      name  = Jeremy.Woo      password  = mypassword [http "https://dev.azure.com"]      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 :- https:// .scm.azurewebsites.net:443/ .git git remote add azure https:// .scm.azurewebsites.net:443/ .git 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)