Test Chef cookbooks with Docker containers

Kitchen Dokken is a provisioner to test cookbooks in Docker containers. It is very fast and efficient compared to cloud instances like AWS EC2s, Vagrant boxes, or VMWare virtual machines.

Currently, you can only test Linux cookbooks with Kitchen Dokken.

To generate a cookbook with the dokken provisioner use the –kitchen option

chef generate cookbook MY_COOKBOOK_NAME --kitchen dokken

The Kitchen Dokken GitHub repository contains more information at https://github.com/test-kitchen/kitchen-dokken

Sample kitchen.yml file with kitchen dokken provisioner at https://github.com/chef-cookbooks/sudo/blob/master/kitchen.dokken.yml

Webinar links at https://www.chef.io/webinars

Silence unknown callers

The new iPhone operating system includes a feature to send all unwanted calls directly to the voicemail. This eliminates the daily car warranty spam calls. If someone calls you from a number that is in your contact list, in your recent outgoing call list, or in a Siri suggestion, the call rings your phone, otherwise it is immediately forwarded to the voicemail. If it was an important call, the caller can leave a message and you can call them back.

To configure your iPhone

  • open Settings
  • select Phone
  • select Silence Unknown Callers
  • slide the switch on the page to show green background

Simultaneous screen sharing in Zoom

Zoom supports simultaneous screen sharing by multiple participants. It is ideal for remote meetings, design sessions, and pair programming. To enable it, configure your Zoom client to use multiple monitors.

  • Open the Zoom preferences
  • On the general tab check Use dual monitors
  • During the meeting in the Share Screen icon select Multiple participants can share simultaneously

Is the Chef aws_s3_file resource idempotent?

Yes, it is idempotent. It means, when the target file on the local drive matches the source file in the S3 bucket, Chef Client does not download the file. In the past aws_s3_file was not idempotent, but now behind the scenes it calls remote_file which compares the files and skips the download when the files match.

     * aws_s3_file[/var/myfile.deb] action create
       * remote_file[/var/myfile.deb] action create (skipped due to not_if)

Chef FATAL: IndexError: string not matched

Chef attributes are “Mash” type.

From the Ruby Doc: “Mash allows you to create pseudo-objects that have method-like accessors for hash keys.” Mash is inherited from Hash.

Attributes can hold any data type, but we need to make sure the type does not change as we create more attributes.

In this example we change the type of the attribute from string to Mash, and Chef throws the error:

FATAL: IndexError: string not matched

# ['level1'] is a string type and contains the string 'value1'
default['level1'] = 'value1'

# The type of ['level1'] changed to a Mash and contains the nested Mash ['name2'] 
default['level1']['name2'] = 'value2'

The solution is, keep the number of levels the same

# ['level1'] is a Mash type and contains the nested Mash ['name1']
default['level1']['name1'] = 'value1'

# ['level1'] is till a Mash type and contains the nested Mash ['name2'] 
default['level1']['name2'] = 'value2'

Get a refund for DMV vehicle registration renewal late payment penalty

If you have never received the vehicle registration renewal notice from the DMV and you have to pay a penalty

aws: command not found

When we want to execute AWS CLI commands to create tags, add AWS keys on AWS instances with the AWS Chef cookbook, first, we need to install the AWS CLI.

On Linux the following lines complete the installation

  bash "install_aws_cli" do
    code <<-EOF
      curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
      unzip -o awscliv2.zip
      # Install AWS CLI and create a symbolic link to it at /usr/bin, otherwise the rest of the AWS CLI calls fail.
      sudo ./aws/install -b /usr/bin --update
    EOF
    not_if 'which aws'
  end

Make sure you use the -b /usr/bin option to instruct the installer to create a symbolic link at /usr/bin

The Amazon recommended -b /usr/local/bin location only works on Amazon Linux and Ubuntu. On CentOS 7 and Red Hat 7 (RHEL7) we get the error message when the aws cookbook is executed

aws: command not found

Change or reset the user password if you cannot logon

I have found an interesting article by Raymond on how to reset the password of your Windows computer even if you cannot log in.

Change Or Reset User Password If You Cannot Logon

For the last method, you will need a bootable USB drive to start your computer. See my article Install Windows 10 from a USB drive on how to create the bootable USB media.

Another suggestion using the bootable media is at I cannot login after Windows 10 update, says “password is incorrect”

Speed up your Windows computer

Windows executes an application every day to check the compatibility of the programs on your computer. Microsoft Compatibility Appraiser runs randomly between 3 am and 5 am in the morning, and in the first 2 hours when you turn on your computer. It can use 30 – 50 % of the CPU slowing down other applications.

To disable it

  • Start the Task Scheduler
  • In the Task Scheduler navigate to Task Scheduler Library, Microsoft, Windows, Application Experience
  • Disable the Microsoft Compatibility Appraiser scheduled task

Transfer streets from maps to Cities: Skylines using transparent film

I have used this fun, but very time consuming “analog” method before discovering the Image Overlay 2 mod described in Transfer streets to your city in Cities: Skylines using a PNG image file

Cities: Skylines is a great environment to build scale models of real cities. In this example, we will transfer the Pacific Electric Railway map of the Los Angeles area from 1947 to the Los Angeles area map by macmcginty. Once you subscribe to the Los Angeles map in the Steam Workshop, the map appears in your map list in Cities: Skylines as “New Map”.

The web page at https://www.pacificelectric.org/pacific-electric/maps/1947-pacific-electric-system-map/ contains the link to the high-resolution scan of the map in PDF format. We can use a Sharpie permanent marker and clear plastic sheets, or Snagit and a printer to transfer the street map to transparent film. We will also need blue painters tape to safely attach the transparencies to the frame of the computer screen.

Determine the zoom scale to use for the Areas view

  • First, open the PDF file in Acrobat Reader to the able to switch out to Windows from the game
  • Start Cities: Skylines
  • Open the map in Cities: Skylines
  • Select the Areas view
  • Measure the distance of two map features in the Areas view
  • Use Alt-Tab to switch to the Acrobat Reader
  • Press CTRL-L for full-screen view
  • Press CTRL-Y to set the zoom scale. Adjust the number to get the same distance of the two features on the PDF map, and write down the number (in my case60 %).

Determine the zoom scale for the edit view

  • In Cities: Skylines press ECS to get back to the edit view
  • Zoom all the way out with the mouse wheel
  • Scroll to the top of the view and set the map to horizontal by holding the middle button (wheel) and moving the mouse left and right
  • Set the tilt to zero by pressing the R key
  • Measure the distance between two objects
  • Switch back to Acrobat Reader and follow the steps above to determine the zoom scale (in my case 322%).

Transfer reference points to the game

First, we will transfer reference points to the game to be able to align the enlarged street layout of the urban areas.

By hand with permanent marker

You can use transparent film and Sharpie permanent marker to transfer the layout first to the film by hand and draw the streets later in the game.

  • Open the map in Cities; Skylines
  • Select the Areas view
  • With blue painter’s tape attach a transparent film to the computer screen.
  • With Sharpie draw the outline of the city and some terrain features to be able to align the film with the PDF map.
  • Switch to Acrobat Reader, and set the already determined zoom scale for the Areas view (in my case60 %)
  • Draw reference points on the transparent film

With printer

We can buy transparent laser or inkjet printable film to transfer the layout of the streets. Make sure to select the correct one for your printer type. If your printer is capable of printing on legal size, 8-1/2″ x 14″ paper, buy that size film, as it will provide a larger area to work with, and it better matches the aspect ratio of the widescreen computer monitors.

In this example, we will use Snagit to capture and print the street map to the transparent film, but you can use any screen capture and graphics program to do that.

  • Open the street map in Acrobat Reader
  • Press CTRL-L for full-screen view
  • Press CTRL-Y to set the zoom scale you have determined above for the Areas view (in my case 60%).
  • Scroll to the view that shows the same area as the region in Cities:Skylines
  • Capture the full screen with Snagit or any other application
  • Open the captured image

Determine the necessary print scale to match the image size on your screen

  • Print the captured image on paper with 100 % scale
  • Measure the distance between two reference points on your screen and on the paper
  • Divide the measured distance on the screen by the measured distance on the paper to get the correct scale to match the screen size on the printout. (0.75 means 75% print scale)
  • Set the calculated scale
  • Set the image position to left to make sure the left size of the captured image is visible on the printout
  • On the Paper tab set the orientation to Landscape
  • Print one more copy on paper to verify the correctness of the determined scale

Print the Areas view

  • On the printer properties window set the
    • paper source to the Rear Paper Feed Slot
    • paper size of the transparency film (legal)
    • orientation to landscape
    • paper type to Premium Presentation Paper Matte
    • If your printer driver has the functionality save the settings as a preset for the future.
  • If the print preview indicates two pages, crop the image to fit on one sheet (in my case the max image height is 1050 pixels)

Transfer some terrain features to the game

  • Switch back to the game
  • With blue painter’s tape attach the transparent film to the computer screen and align it with the Areas view.
  • By switching between the editor and the Areas view, use the Wide canal tool in the Landscaping, Water Structures menu, as it is highly visible on the Areas view, to transfer the reference terrain features to the game.

Transfer the street map to the game

  • Open the street map in Acrobat Reader
  • Press CTRL-L for full-screen view
  • Press CTRL-Y to set the zoom scale you have determined above for the edit view (in my case 322%)
  • Scroll to the area of your interest

If you use Sharpie

  • With blue painter’s tape attach a transparent film to the computer screen.
  • Copy the tram lines, major streets, and train tracks with Sharpie permanent marker to the transparent film.

If you use a printer

  • Capture the view on the screen
  • Crop the image if necessary
  • Make sure the scale and print setting are correct (in my case 1050 pixels height, 75% print scale)
  • Print the captured image on the transparency film
  • Lay the print flat on the table and let the ink dry for a few minutes.

Draw the streets

  • Switch back to the game
  • In Cities: Skylines press ECS to get back to the edit view
  • Zoom all the way out with the mouse wheel
  • Scroll to the top of the view and set the map to horizontal by holding the middle button (wheel) and moving the mouse left and right
  • Set the tilt to zero (looking down vertically) by pressing the R key
  • With blue painter’s tape attach the transparent film to the computer screen.
  • Align the film with the map in the game and draw the features in the game.