Thursday, May 28, 2020

Running chrome with CORS disabled

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --disable-gpu --user-data-dir=~/chromeTemp

Thursday, May 14, 2020

Example of dockerfile and how to bake in locally.

FROM mcr.microsoft.com/dotnet/core/sdk:3.1

Add bin/Debug/netcoreapp3.1/publish /var/foo/bin
WORKDIR /var/foo/bin

EXPOSE 5000/tcp
ENV ASPNETCORE_URLS http://*:5000

ENTRYPOINT ["dotnet", "Company.Project.dll"]

To bake in solution file folder run

dotnet publish

In *.csproj folder run

docker build -t testingdocker .
docker run -lt testingdocker --entrypoint bin/bash


Notice that there is a dot (.)

Monday, May 11, 2020

AZ and kubectl commands to save a day

kubectl commands run in a context of Azure account. On a fresh machine, one needs to first install az command line and login to azure, with an azure username (in many companies it is a sys account).

az login

when you run

az account show

You should see something similar to:

{ "environmentName": "AzureCloud", "homeTenantId": "ced47777-d73a-4514-a74d-63af7885ff7d", "id": "a75c7777-66c1-4373-a0f3-859abaefcccc", "isDefault": true, "managedByTenants": [], "name": "Company - Development - DEV", "state": "Enabled", "tenantId": "ccc47db0-d73a-4514-a74d-63af7885ff7d", "user": { "name": "ME@mycompany.com", "type": "user" } }

name property is important because it is an active subscription against which kubectl commands will run. You can change it by running:

az account set --subscription "Company - Production - LIVE"

you can pull resource group to be able to manage it, by running:

az aks get-credentials --name platform-aks-dev-ne --resource-group platform-aks-dev-rg-ne

now you are able to manage all pods, by running:

kubectl get pods

or

kubectl get pods -n foo-dev

where foo-dev is a namespace. To get all events you can run

kubectl get events --namespace foo-dev

Tuesday, January 15, 2019

Deleting old records in large table in SQL Server

Let's face it DELETE command is really slow. It is often quite a challenge to delete multiple records. If there is no WHERE clause then it is much better to use TRUNCATE, but if you have to use WHERE you are back to square one :). This is my approach how to use DELETE command on a large set of data:


DECLARE @rows INT = 1
SET @rows = 1

WHILE @rows > 0
BEGIN
DELETE TOP (5000) [dbo].[MyLog]
WHERE CreationDateTime <= DATEADD(MONTH, - 6, GETDATE())

SET @rows = @@ROWCOUNT;
END

Tuesday, April 3, 2018

ORA-01795: maximum number of expressions in a list is 1000

ORA-01795: maximum number of expressions in a list is 1000
01795. 00000 -  "maximum number of expressions in a list is 1000"
*Cause:    Number of expressions in the query exceeded than 1000.
           Note that unused column/expressions are also counted
           Maximum number of expressions that are allowed is 1000.
*Action:   Reduce the number of expressions in the list and resubmit.
Error at Line: 1,002 Column: 1

This is one of the differences between SQL server (management studio) and Oracle (Oracle SQL developer). It is especially problematic when I have a list of values in where statement. Use SQL server whenever possible.

Friday, March 9, 2018

github user set localy for the project

Often git user that I use on my machine is related with the company that I am working for. Sometimes I need to access my personal repositories to get some useful code, snipped or component that I can use. Sometimes during this process I modify something in that component and I want to push it to github as me and not as a different git user. Important part is to set local git preferences for the project; following commands are useful:

git config -llist all the config for git
git config -l --locallist config that is specific for given project
git config -l --globallist global configuration


Edit local config, set github username and email address to the one that is used in github.
git config -e --local

Set following fields:
[user] 
 email = foobar@gmail.com 
 name = FirstName LastName 


Not being able to login to npm -- npm adduser not working

In various organisations it is common to code in environment that requires you to connect to a organisation specific repository or to use a specific user. Sometimes you want to push your package to a global npm (https://registry.npmjs.org/) repository and the process doesn't work. What I enjoy doing is to setup a local .npmrc file inside a project structure. Inside it I specify the registry configuration like:

registry = "https://registry.npmjs.org/"

adduser command runs in a scope of a registry. Often when you try to use it it tells you that your username doesn't exist, or user was incorrect because you were verifying against a server that is specified by registry parameter. Without running adduser command often your environment will pickup user credentials that are specified by your systeadmins and are related to a registry that is specific for the organization. That's why when you run following command w/o running ever adduser it often displays username:



If you run adduser command in a directory that has registry set to a different location your result will be different:


It is worth noticing that adduser command doesn't add any lines to local .npmrc file. File will only contain registry entry.