Showing posts with label tools. Show all posts
Showing posts with label tools. Show all posts

Saturday, September 25, 2021

alias for git commands

To combine add and commit it is easy to create an alias:
git config --global alias.ac "commit am"

now in command line instead of running
git commit -am "this is my commit"

you can run
git ac "this is my commit"

Monday, July 19, 2021

Generating pfx file with multiple certificates.

One pfx file can have multiple certificates inside it. In order to create such file, the easiest way is to copy paste all the *.crt files into one file so the file content will be similar to this one:

-----BEGIN CERTIFICATE----- MA0GCSqGSIb3DQEBCwUAA4IBAQAIfmyTEMg4uJapkEv/oV9PBO9sPpyIBslQj6Zz 91cxG7685C/b+LrTW+C05+Z5Yg4MotdqY3MxtfWoSKQ7CC2iXZDXtHwlTxFWMMS2 RJ17LJ3lXubvDGGqv+QqG+6EnriDfcFDzkSnE3ANkR/0yBOtg2DZ2HKocyQetawi DsoXiWJYRBuriSUBAA/NxBti21G00w9RKpv0vHP8ds42pM3Z2Czqrpv1KrKQ0U11 GIo/ikGQI31bS/6kA1ibRrLDYGCD+H1QQc7CoZDDu+8CL9IVVO5EFdkKrqeKM+2x LXY2JtwE65/3YR8V3Idv7kaWKK2hJn0KCacuBKONvPi8BDDD -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- GGGEfTCCA2WgAwIBAgIDG+cVMA0GCSqGSIb3DQEBCwUAMGMxCzAJBgNVBAYTAlVT MSEwHwYDVQQKExhUaGUgR28gRGFkZHkgR3JvdXAsIEluYy4xMTAvBgNVBAsTKEdv IERhZGR5IENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTQwMTAx MDcwMDAwWhcNMzEwNTMwMDcwMDAwWjCBgzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- AAAEfTCCA2WgAwIBAgIDG+cVMA0GCSqGSIb3DQEBCwUAMGMxCzAJBgNVBAYTAlVT MSEwHwYDVQQKExhUaGUgR28gRGFkZHkgR3JvdXAsIEluYy4xMTAvBgNVBAsTKEdv IERhZGR5IENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTQwMTAx MDcwMDAwWhcNMzEwNTMwMDcwMDAwWjCBgzELMAkGA1UEBhMCVVMxEDAOBgNVBZZZ -----END CERTIFICATE-----


This is just an example, the certificate section for each certificate will be larger. Let's call such file bundle.crt<\i>. In order to sign it we need a key - key is just a file with a content similar to the *.crt file - some people call it pem files. Generally speaking *.crt, *.pem, *.cert are files that have this same content in this same format, the only difference is just a file extension. To create a pfx file we need an openssl application. You can get the windows binaries from here: ssl binaries. I used the openssl-1.0.2r-x64_86-win64.zip.

To generate pfx I run:
openssl pkcs12 -export -out Private.pfx -inkey C:\cert.key -in C:\bundle.crt

You will need to provide a password for this key and retype it.


If you want to see what is inside pfx you can run:
certutil -dump Private.pfx

certutil is a tool that is by default installed on Windows machine. If you have openssl installed you can run:
openssl pkcs12 -info -in Private.pfx

You need the password in order to run these commands.

Tuesday, November 17, 2020

Check password policy in AD

You need to install first Active Directory Powershell cmdlets on Windows 10. This cmdlets alloweds a user to check the policy.

Get-WindowsCapability -Online | Where-Object {$_.Name -like "*ActiveDirectory.DS-LDS*"} | Add-WindowsCapability -Online


With a cmdlets you can call
get-addomain | get-adobject -properties * | select *pwd*

Thursday, August 20, 2020

Conda virtual environment management

To list all env:
conda env list


To create:
conda create --name myenv

To create with a specific version of python
conda create -n myenv python=3.6

To activate:
conda activate myenv

To go back to base env:
conda deactivate

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

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 


Thursday, May 26, 2016

Waking up Heroku app

Deployment is not enough to wake it up. I just hit the URL in the browser :) Unfortunately if you use a free dyno for a hugbot that is integrated with slack, you need to wake your dyno up after recharging period.

young-sands-45836.herokuapp.com

Friday, January 29, 2016

Jenkins: Couldn't find any revision to build. Verify the repository and branch configuration for this job.


If you see following error in Jenskins build and you are using git:
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
It is because someone moved some git branches around, and they are missing. Instead of selecting a branch in Jenkins config modify advance input with:
+refs/heads/foo/bar:refs/remotes/origin/foo/bar

Tuesday, January 5, 2016

Nuget repository only looks at Microsoft repository

Recently few things changed in Nuget word. Currently when I run:
get-packages -ListAvailable
It only shows packages from Microsoft.
To be able to use Nuget repo again and be able to install typical libriaries like NUnit one has to add NuGet.Config to a folder that holds the solution file.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="NuGet official package source" value="https://nuget.org/api/v2/" />
    <add key="local" value="C:\development\PathToYourLocalNugetRepositoryIfYouNeedIt\NugetLocal" />
  </packageSources>
</configuration>

After modification, Manage NuGet Packages tool should show All, NuGet official package source, local, Microsoft and .NET.

Wednesday, July 15, 2015

Jenkins: ERROR: Failed to update

My dev machine was building code correctly, and everything was running. Unfortunately CI environment was throwing following exception.
[iTROPICS-TRUNK] $ "C:\Program Files\TortoiseHg/hg" --config auth.jenkins.prefix=* --config ******** --config ******** --config "auth.jenkins.schemes=http https" update --clean --rev default
abort: C:\Jenkins\Workspace\iTROPICS-TRUNK\src/TTC.iTropics.ServiceReferences/Service References/iTropicsBrokerBuildWS/TTC.iTropics.ServiceReferences.iTropicsBrokerBuildWS.com_tropics_webservice_iTropics_vo_current_common_WSGetAssociatedMiscProductsResponse.datasource: The system cannot find the path specified
ERROR: Failed to update
ERROR: Failed to update
It is because machine hit the maximum path length – 260 chars.

Saturday, April 18, 2015

WinDbg strikes back

Typical problems with winDbg:

.loadby sos mscorwks
Unable to find module 'mscorwks'


for .NET framework 4+ use
.loadby sos clr

SOS does not support the current target architecture.


I see this exception when I run multiple commands because dump was created on 64 bit arch for 32 bit process (I still recommend taking dump using 32 bit Task Manager that is located under C:\Windows\SysWOW64).
!wow64exts.sw
Helps to run some commands like
!clrstack

Tuesday, February 24, 2015

Universal Google Analytics Event Tracking Problems

I keep receiving a following error under Google GA Debugger plugin in Chrome:

Command ignored. Unknown target: undefined

In Google Analytics (GA) I do not see any events. I am using Universal Google Analytics and I attached it to a page thru Google Tag Manager (GTM).
When I change in GTM Tag Type from Universal Anaytics to Custom HTML Tag and paste manually GA code everything works.

Solution to the problem is to set a Tracker Name in GTM config

and raise events in a following way (Tracker Name is set to internalTrackerName):
ga('internalTrackerName.send', 'event', 'button', 'click', 'View Bookings');

Saturday, January 24, 2015

Adding already existing project to GitHub using command line

A typical problem that I often have, playing with various repositories and frameworks is how to add already existing project to a remote repository. In this tutorial I show how to do it for a GitHub mostly by using a command line. I assume that git environment is already set up and that there is already a working environment that is able to push/pull data from GitHub. For windows the only thing that one has to do is to install GitHub for windows.
  • 1. Create a new repository in GitHub - it means go to GitHub page, login, add a new repository. This is the only step that requires doing something not in a command line. I will create a my-app repository, so it will be available under https://github.com/sagasu/my-app
  • 2. Open a git shell.
  • 3. Navigate to a project directory. Actually you have to 'cd my-app', and be in a directory with a project files.
  • 4. git init
  • 5. git add .
  • 6. git commit -m 'message'
  • 7. git remote add my-app https://github.com/sagasu/my-app
  • 8. git push -u my-app master

Saturday, December 13, 2014

Windows Update error 0x80073712

I was not able to install Windows 8.1 Update for x64-based Systems (KB2919355), For a last few months. It's not like I was trying to do it everyday, simply when I noticed that I am not able to install it I tried again after few weeks. Unfortunately this update is required for me to install other update that is required to play with new .NET 4.6 preview framework (link to Visual Studio 2015 download, because that's the place that allowed framework to be downloaded).

What didn't work


Using File System Checker to repair missing or corrupted system files

sfc /scannow

Running in cmd as Admin following commands

net stop wuauserv
net stop bits
net stop cryptsvc
ren %systemroot%\System32\Catroot2 Catroot2.old
net start cryptsvc
ren %systemroot%\SoftwareDistribution SoftwareDistribution.old
regsvr32 wuapi.dll
regsvr32 wuaueng.dll
regsvr32 wucltux.dll
regsvr32 wups2.dll
regsvr32 wups.dll
regsvr32 wuwebv.dll
net start bits
net start wuauserv
net start Eventlog
exit

What resolved the problem


Running in cmd as Admin following commands

DISM.exe /Online /Cleanup-image /Scanhealth

DISM.exe /Online /Cleanup-image /Restorehealth
DISM process failed few times when I run it.

Monday, December 8, 2014

Run psake task from powershel


I constantly keep forgeting this command, because I use it once per few months. Here is how to trigger a psake task from pshell:
.\psake.ps1 "<fileWithTasks.ps1>" "<taskName>"

Some example:
.\psake.ps1 "default.ps1" "UpdateDatabase"

Monday, September 16, 2013

What to do if there is no FireBug installed in Firefox


I noticed that many Firefox users are unaware that since version 11 firefox introduced a tool that is similar to firebug. You can trigger it by hitting:
Shift+F7

I sometimes debug/trace an issue not from a development machine, and I don't have an access to firebug, so it is worth to remember, that Style Editor is there to help you.

Thursday, August 8, 2013

Proxy Ignore List for IE (ProxyOverride)

It is really easy to ignore proxy for a specific URL under Firefox.

You simply go to:
 Tools->Options->Advanced->Network->Connection Settings 
and add url to No Proxy list.
There is no such inteface for IE or Chrome. In order to add URL to ignore list you need to modify registry:
HKEY_USERS\[UserID]\Software\Microsoft\Windows\CurrentVersion\Internet Settings

And add your entry to ProxyOverride list.