Dev & Ops Notes and more
- Dev & Ops Notes and Tools
- To have a quick reference on installing/using some nice tools for primary Windows owners
Add EditorConfig plugin Tools>Install Package>EditorConfig
- https://github.com/MorganGeek/bookmarks
- Building a Deployment Pipeline for .NET
- This PowerShell module contains cmdlets to query instances of Visual Studio 2017 and newer
From the folder WindowsTools\Chocolatey, run with administrative privileges install_Chocolatey.bat
Goto https://chocolatey.org/install and follow the steps
- Long version
choco install mySensationalPackage
- Using the alias
cinst mySensationalPackage
... a large collection of GNU and Open Source tools which provide functionality similar to a Linux distribution on Windows
-
Open a command prompt in Administrator mode
-
Be sure that Chocolatey is installed. Run the following command
choco install cyg-get
- On Windows search box write Cygwin
- A terminal windows must appear as following
- The terminal window is opened to a large collection of GNU and Open Source tools
... enables users to create and configure lightweight, reproducible, and portable development environments
-
Open a command prompt in Administrator mode
cyg-get openssh cyg-get rsync cyg-get ncurses
-
Install a hypervisor (Hyper-V or VirtualBox). Hyper-V on windows is a feature
-
If you like VirtualBox or need access to USB from guest VMs, use chocolatey to install
cinst virtualbox
Using chocolatey
cinst vagrant
A fast and furious howto...
-
Goto https://app.vagrantup.com/boxes/search? and find the box you are looking for. For example, I am looking for CentOs box built for hyperv
-
Open a Cygwin terminal in administrative mode
-
Count to four and you're done. Assuming that you are new kid on the block and haven't customized vagrant file, just type the following commands in the Cygwin terminal...
mkdir centos cd !$ vagrant init centos/7 vagrant up --provider=hyperv
If you are virtualbox fun, just switch hyperv with virtualbox in the --provider argument
-
Usefull commands
vagrant status vagrant global-status vagrant reload vagrant halt vagrant ssh vagrant destroy
... tool that automates the creation of any type of machine image
-
Open a command prompt in Administrator mode
-
Be sure that Chocolatey is installed. Run the following command
cinst packer
docker ps
Knowing the name you provided it is easy to stop the container
docker stop <your-container-name>
docker logs --tail 1000 <your-container-name>
Delete images sourced from the "thereponame"
&docker images --format "{{.Repository}}:{{.Tag}}" | foreach { $_.split(' ')[0]} | where-object {$_ -Like "thereponame*"} | foreach {docker image rm $_}
Presuming that we have a doduck
image with tag dev
&docker ps --filter "status=running" --filter "ancestor=doduck:dev" --format "{{.Names}}" | foreach {docker inspect --format '{{ .NetworkSettings.Networks.nat.IPAddress }}' $_ } | Select-Object -first 1
FOR /F "tokens=*" %m IN ('docker ps --filter "status=running" --filter "ancestor=doduck:dev" --format "{{.Names}}" ') do (FOR /F "tokens=*" %g IN ('docker inspect --format "{{ .NetworkSettings.Networks.nat.IPAddress }}" %m') do (SET DODUCKIP=%g))
echo %doduckip%
FOR /F "tokens=*" %%m IN ('docker ps --filter "status=running" --filter "ancestor=doduck:dev" --format "{{.Names}}" ') do (FOR /F "tokens=*" %%g IN ('docker inspect --format "{{ .NetworkSettings.Networks.nat.IPAddress }}" %%m') do (SET DODUCKIP=%%g))
echo %doduckip%
On Windows 10 1709 you may run LCOW containers with the addition of --platform=linux.
- Switch to Windows containers
- All linux containers must be triggered with --platform=linux
How to containerize .NET MVC or WebForms app
From a powershell console opened as Administrator run:
Invoke-WebRequest -Uri "https://github.com/clns/gitlab-cli/releases/download/0.3.2/gitlab-cli-Windows-x86_64.exe" -OutFile "gitlab-cli.exe"
move "gitlab-cli.exe" C:\Windows\System32\
Create a file named .gitlab-cli.yaml in %HOMEPATH% with content as followings.
---
repos:
eng2_new:
url: http://gitlab.yourdomain.io/mircea.matei/eng2
token: bp6t2f2fx2M4BACdWGle
devop4:
url: http://gitlab.yourdomain.io/mircea.matei/devop4
token: bp6t2f2fx2M4BACdWGle
The token will be generated from YourUser=>Settings=>Access Tokens
git config --list --show-origin
git config --system core.longpaths true
Find large files commits
git rev-list --objects --all | grep "$(git verify-pack -v .git/objects/pack/*. idx | sort -k 3 -n | tail -10 | awk '{print$1}')"
git config --global core.autocrlf false
git config --global core.eol lf
git rm --cached -rf .
git diff --cached --name-only -z | xargs -n 50 -0 git add -f
cd src/yourlfcleanfolder
git ls-files -z | xargs -0 rm
git checkout .
A quick article that may help you.
Sourcetree is Git GUI for Windows
Plugin to IntelliJ IDEA for quickly start new Branch/Feature/Patch
Understanding structure https://svn.apache.org/repos/asf/subversion/trunk/doc/user/svn-best-practices.html Sample strategy https://www.getfilecloud.com/blog/a-svn-branching-strategy-that-works/
Quick installation guide for CentOS is here
(Powershell) WinRM to configure and WinRS to execute
On the remote target assure that winrm is configured. From a powershell console run:
winrm quickconfig
Place a script on the remote target and call the script remotely from the local machine
winrs -r:the_remote_server powershell -file C:\admin_repo\check_status.ps1
- Use appwiz.cpl to enable it.
- Command to pursue
lxrun /install
If environments was modified in another console
refreshenv
https://linoxide.com/linux-how-to/setup-openshift-origin-centos-7/ or using openshift-ansible
oc login -u system:admin -n default --config=/etc/origin/master/admin.kubeconfig
oc adm policy add-cluster-role-to-user cluster-admin mirceam --config=/etc/origin/master/admin.kubeconfig
Add the followings section to Triggers section of desired BuildConfig
triggers:
- gitlab:
secret: 1234f932f43f9d45
type: GitLab
In GitLab go to Settings=>Integration and add a Webhook like the image shows
sudo sysctl -w vm.max_map_count=262144
ng serve --ssl 1 --ssl-key "ssl/yourdomain.io.key" --ssl-cert "ssl/yourdomain.io.crt"
{
"version": "0.2.0",
"configurations": [
{
"name": "ng serve",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200/#",
"webRoot": "${workspaceRoot}"
},
{
"name": "ng test",
"type": "chrome",
"request": "launch",
"url": "http://localhost:9876/debug.html",
"webRoot": "${workspaceRoot}"
},
{
"name": "ng e2e",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/protractor/bin/protractor",
"protocol": "inspector",
"args": ["${workspaceRoot}/protractor.conf.js"]
}
]
}
If you need to remember tasks and their start position in code, place todo marker wherever you need. Visual Studio will recognize them automatically and will place them in the "Task List" (View menu => Task List).
// todo #124. Issue on serializing culture dependent strings
The todo marker is case insensitive. Todo, toDo, todo are valid forms.
Azure various notes
Login-AzureRmAccount
Set-AzureRmAppServicePlan -ResourceGroupName $YourAzureResourceGroup -Name $YourAzureResourcePlan -Tier Free
In order to test a mobile app service guarded by an identityprovider, you may use Postman. The following example use facebook as identity provider. Point your browser to https://yourservice.azurewebsites.net//.auth/login/facebook The returned URL if it is URLdecoded contain a token in JSON format
https://yourservice.azurewebsites.net/.auth/login/done#token={"authenticationToken":"####thetokenstring#####","user":{"userId":"sid:#####ausersid#####"}}
Start a GET in Postman with two headers:
- ZUMO-API-VERSION with value 2.0.0
- X-ZUMO-AUTH with value ####thetokenstring##### copied from the returned URL
A great tool for automatically translate a bunch of res files to many languages. Install it as tool in Visual studio 2017. Create a free subscription on your Azure account, add a translator service, copy the key from keys, add it to your Credential Manager and you are ready to go. Read this
It works like a charm (PM 1.0.2 / XF 3.0.0.561731). Pay attention when adding a new translation to:
- Add translation language from project context menu M.A.P.
- Go to xlf file (in Solution Explorer) and change property "Build Action" to "XLIFF Localization File"
- Access "Generate machine translations" from the xlf file M.A.P. context menu
- Rebuild the project
adb devices
adb shell
Start a shell and run next...
run-as com.myapp ls -l /data/data/com.myapp/files/myappdatabase
Start a shell and run next...
adb pull /data/data/com.myapp/files/myappdatabase
If not allowed ...
adb shell "run-as com.myapp chmod 666 /data/data/com.myapp/files/syncstore_myapp.db"
adb exec-out run-as com.myapp cat /data/data/com.myapp/files/syncstore_myapp.db > syncstore_myapp.db
adb shell "run-as com.myapp chmod 600 /data/data/com.myapp/files/syncstore_myapp.db"
Generate a new package with Android Studio.
Add your code
All the following steps will be penalties if not provided
- Add a test
- Add an example
- Add 160-180 length description in pubspec
- Comment your code
- Add a license
# format
flutter format [filename]
# test publish constraints
flutter packages pub publish --dry-run
# publish
flutter packages pub publish
flutter packages pub global activate dartdoc
flutter packages pub global run dartdoc:dartdoc %*
A quick how-to on https://github.com/flutter/flutter/wiki/Making-animated-GIFs-of-Flutter-apps
What is FAKE? "A DSL for build tasks and more with the power of F# -anywhere, -anytime" (Quote from the official site https://fake.build/ )
Run in the root of the repository the following commands:
dotnet new tool-manifest
dotnet tool install fake-cli
For an example how to build a .NET solution (passed as parameter) with Msbuild check this script
Features:
- Accept one parameter for the sln file that will be target for the build
- Searching inside src folder for the name received as parameter
- It cleans the ouptut folder
- The build output is placed in a configurable destination
dotnet fake run ./build.fsx MyFunnySolution
https://marketplace.visualstudio.com/items?itemName=ms.vss-exploratorytesting-web