Refresh the environment variables in the Windows Command Prompt and PowerShell window

When the Windows Command Prompt and PowerShell windows open, they read the environment variables from the registry. If another process changes the value of an environment variable or creates a new one, the already open windows don’t reflect those changes. To reload the environment variables into open Command Prompt and PowerShell windows execute

refreshenv

Install Git on Windows

If you use two-factor authentication see Create a Personal Access Token to use it as password in the command line tools at Switching to 2-factor authentication in GitHub

  1. Navigate to https://git-scm.com/download/win to download Git for Windows. The page automatically downloads the installer for the operating system you use.
  2. Install the application
  3. Accept the default values, including these:
    1. Make sure the File Explorer integration for Git Bash is checked.
    2. Enable the Git tools in the command prompt too
    3. HTTPS transport backend. For large corporations with internal root certificates and  Windows Active Directory, the second option may be a better choice,
    4. Line endings for Windows computers
    5. Terminal emulator
    6. Use Fast Forward or Merge
    7. Use the Git credential manager
    8. Caching
    9. Finish the installation.

Configure Git for Windows

Enable Page Up and Page Down

  1. In File Explorer right-click any folder and select Show more options
  2. Select Open Git Bash here,
  3. Stretch the Bash window to the full width of the page to have more room to work later,
  4. Right-click the Bash window and select Options…,
  5. On the Window tab,
    1. Click the Current size button to save the size,
    2. Select PgUp and PgDn scroll without modifier to be able to scroll quickly up and down in the window with the Page up and Page down buttons.
    3. Click the Save button

Set up Git Bash to always run as Administrator

Certain commands need elevated rights to run, so we will set up the Bash window to run as administrator.

  1. Type bash into the search field
  2. Right-click the found link and select Open file location
  3. Right-click the menu shortcut and select Properties
  4. On the Compatibility tab select Run this program as administrator

Dubious ownership warning

If you already created a Git repository on your computer as the default user, and you have to use a different Admin account to run the terminal in admin mode you will get the error message when you try to execute any Git command in that repository:

$ git status
fatal: detected dubious ownership in repository at ‘C:/Users/…’
‘C:/Users/…’ is owned by:

but the current user is:

To add an exception for this directory, call:

git config --global --add safe.directory C:/Users/...

Execute the recommended command to enable multiple user accounts to manage the same repository.

Using the Bash window

  • When you will start the Git Bash window you will always get the confirmation popup. You may need to enter your admin credentials if your default user does not have admin rights.

You can start the Git Bash window from the File Explorer

  1. In File Explorer right-click any folder and select Show more options
  2. Select Open Git Bash here,

Configure the Git command line tool

To configure Git see Git configuration.

Install Chocolatey

The Chocolatey home page is at https://chocolatey.org/

Install Chocolatey

Navigate to the Chocolatey website at https://chocolatey.org/ and follow the latest instructions. At the time of writing the instructions were

Using the Command prompt

  1. Open a command prompt as Administrator,
  2. Install Chocolatey with the command
    @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

Using PowerShell

  1. Open a PowerShell window as Administrator,
  2. Check the execution policy for your computer
    Get-ExecutionPolicy
    1. If the command returns Restricted, enable PowerScript execution with
      Set-ExecutionPolicy Bypass -Scope Process
    2. Answer Y to the question,
  3. Install Chocolatey with
    Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

Apply the Chocolatey license

  1. If the C:\ProgramData\chocolatey\license directory does not exist, create it,
  2. To place the Chocolatey license file, chocolatey.license.xml into C:\ProgramData\chocolatey\license folder follow the recommendations at …refers to a location that is unavailable
  3. Install the Chocolatey extensions
    choco upgrade chocolatey.extension -y

Ignore the error:

Error when attempting to load chocolatey licensed assembly. Ensure
that chocolatey.licensed.dll exists at
‘C:\ProgramData\chocolatey\extensions\chocolatey\chocolatey.licensed.dll’.
Install with `choco install chocolatey.extension`.
The error message itself may be helpful as well:
The system cannot find the file specified. (Exception from HRESULT: 0x80070002)

The instance ID ‘…’ does not exist

When you launch an EC2 instance in AWS and the Chef script is trying to set tags on the instance you may get the error message:

The instance ID ‘…’ does not exist

It can happen when you launch the instance in one AWS account, and the tagging script tries to find the instance in another account.

Solution

When the tagging script runs make sure, the AWS credentials and the region point to the account and region where the instance was launched.

Determine the Windows PowerShell version

To reliably display the version of the Windows PowerShell engine

  1. Open a PowerShell command window,
  2. Execute the command,
    $PSVersionTable.PSVersion

    PS C:\WINDOWS\system32> $PSVersionTable.PSVersion

    Major Minor Build   Revision
    —–   —–   ——-  ——-
    5       1        16299  64

  3. If no value is displayed, the version is 1.0, as it does not have the referenced variable.

How to create a slideshow in Drupal 7

To create a slideshow in Drupal 7

Create a Slideshow content

  1. Log into Drupal as administrator
  2. In the top menu select Content and Add content
  3. On the Add Content page select Slideshow
  4. On the Create Slideshow page enter the title of the page, and populate the fields for the images. Click the Choose File to upload the image.
  5. Click the Add another item button to add the next image.
  6. Write down the Node ID from the address bar. You will refer to it in the slideshow module,
  7. Click the Save button at the bottom to save the page.

Create a Structure for the slideshow

  1. In the top menu select Structure, and on the page click View,
  2. If there is an existing slideshow with the required settings
    1. Clone it,
    2. Enter a new name for the view,
  3. If you need a new slideshow type
    1. Click the Add view from template link,
    2. Click the add button in the Image Gallery line,
    3. Enter a name for the new view and click the Continue button,
  4. Click the Content: Nid (=) link to select the images uploaded in the content section above,
  5. Enter the Node ID you saw in the address line above and click the Apply button,
  6. To set the block name click the block name link,
  7. Enter a block name,
  8. Click the Save button to save the view.

Add the slideshow to a page

  1. Add the page to the menu, navigate to it, and copy the page address to the clipboard that follows the domain name,
  2. In the main menu select Structure, and on the Structure page select Blocks,
  3. Find the block In the Disabled section and in the drop-down select Content. The block will jump to the Content section,
  4. Find the bock in the Content section and click the configure link,
  5. In the REGION SETTINGS section select Content in the drop-down,
  6. On Pages tab of the Visibility settings section select the Only the listed pages radio button, and enter the address of the page,
  7. On the block configuration page click the Save block button.
  8. On the Blocks page click the Save blocks button.

Edit the slideshow

Log into the site as an administrator

To add or delete pictures

  1. In the upper left corner click the Edit link.

To edit the slideshow settings

  1. Move the mouse above the slideshow,
  2. In the upper right corner click the gear icon,
  3. Select the edit page from the menu.

How to install a Drupal module

To install a Drupal module

  1. Download the Drupal module from the www.drupal.org website,
  2. Unzip the module,
  3. With an FTP client upload the module directory to sites/all/modules/contrib
  4. Log into the Drupal site as administrator,
  5. In the menu select Modules,
  6. Click the switch next to the module name to turn it ON. The orange switch label reminds you to save the changes.
  7. Click the Save configuration button in the lower left corner,
  8. The green ON switch indicates that the module has been successfully enabled.

How to create a Docker repository in Artifactory

Artifactory supports multiple repository types, Docker is one of them. To create a new Docker repository in Artifactory

Set the Custom Base URL of the Artifactory server

From the Artifactory documentation at https://www.jfrog.com/confluence/display/RTF/Configuring+NGINX

“When using an HTTP proxy, the links produced by Artifactory, as well as certain redirects contain the wrong port and use the http instead of https”

  1. On the left side select Admin,
  2. Under Configuration on the General page enter the actual URL you use to access the Artifactory server and click the Save button.

Create one virtual Docker repository for all of your Docker repositories

As recommended by the Artifactory documentation at https://www.jfrog.com/confluence/display/RTF/Configuring+a+Reverse+Proxy#ConfiguringaReverseProxy-DockerReverseProxySettings
create one virtual Docker repository to aggregate all other Docker repositories, so only this repository has to be set up on the reverse proxy server.

  1. On the left side select Admin,
  2. In the Repositories section on the Virtual page click New,
  3. Select the Docker package type,
  4. Enter a name for the repository,
  5. Command-click (CTRL-click on Windows) the configure reverse proxy link to open it in a new tab and generate the script to set up the reverse proxy server,

Create the reverse proxy script

  1. In the Configuration section on the Reverse Proxy page fill out the form. If the reverse proxy server will be installed on the Artifactory server, write localhost in the Internal Hostname field.

    If you use a load balancer in front of the Artifactory server that also contains the SSL certificate you don’t need to enable the HTTPS protocol. If you use wildcard certificate you can select the Sub Domain reverse proxy method.

Save the Virtual repository

  1. On the New Virtual repository tab click Next at the bottom of the page,
  2. The Advanced tab shows the name of the Docker Registry
  3. Click the Save & Finish button to create the repository.

Create the Docker local repository

The local Docker repository will store the Docker images

  1. On the left side select Admin,
  2. In the Repositories section on the Local page click New,
  3. Select the Docker package type,
  4. Enter a name for the repository and click Next,
  5. The Advanced tab shows the address of the repository using the reverse proxy,
  6. Click the Save & Finish button to create the repository.

 

How to transfer an Atlassian Confluence wiki space to another server

Confluence is one of the most popular Wikis with a great user interface. To export and transfer an Atlassian Confluence wiki to another server

  1. Log into the Atlassian Confluence wiki as an administrator,
  2. In the lower left corner click the gear icon and select Content Tools,
  3. On the Export tab select the XML radio button and click Next,
  4. Select Custom Export and click the Export button at the bottom of the page,
  5. The export process starts,
  6. Click the link to download the export file,

Atom text editor configuration

Configure Atom

Turn off auto-indent on paste to stop Atom reformatting your code.

  1. In the Atom menu select Preferences
  2. On the left side select Editor
    • Uncheck Auto Indent On Paste
    • Check Show Indent Guide
    • Set Tab Type to soft to place 2 spaces when you press the tab key

Atom language packs

Atom language packs help you with code completion.

Install language packs

  1. In the Atom menu select Preferences…
  2. On the left select Install, and type the name of the language pack into the text box and hit enter. Click the Install button to install the language pack.
    – language-chef
    – language-inspec

How to use language packs

  1. Start to type the name of the resource, and a list appears with the matching resources.
  2. Select the resource in the list with the cursor keys and press tab to insert the code snippet
  3. Make the appropriate changes to customize the resource.

Line endings

Set Atom to always use “LF” as the line ending.

  1. In the Atom menu select Preferences
  2. On the left side select Packages
  3. Select the line-ending-selector package
  4. Set the Default line ending to LF

Configure Atom to insert tabs into the Makefile

Makefiles need tabs instead of spaces otherwise we get the error message

Makefile:2: *** missing separator. Stop.

To configure Atom to always use tabs in Makefile

  1. Set the Tab Type to auto in the Atom settings
  2. Install Editorconfig with
    apm install editorconfig
  3. Create the .editorconfig file in the root of your project directories (~/Git) with the content
    [Makefile]
    indent_style = tab
    
    [*.yml]
    indent_style = space
    indent_size = 2
  4. Restart Atom