linux macbook, ubuntu

This is my old MacBook Mid 2009. It was sitting in the closet for so long I thought I could invent some purpose and use it before it finally dies. Looks like latest macOS version don’t even support this device so I thought maybe I could use it as a learning tool for Ubuntu.

Since SSDs are so cheap these days I just decided to keep the old macOS drive as backup and install Ubuntu on one of these babies:

I think around £18 is a small price to pay for a brand new SSD so went with it.

Installing Ubuntu

  1. Download the ISO here

  2. Burn the ISO to a USB Drive. Instead of installing extra software I followed this guide: Making a Kali Bootable USB Drive. It’s for Kali Linux but this bit works for burning any Linux distro.
  3. For the rest follow the steps here starting with Step 9

And after the installation this is what my MacBook looks like:

Resources

hobbymisc productivity, apple_watch, alexa, philips_hue, iot

My #1 rule for productivity is “No Snoozing!”. If you snooze, it means you are late for everything you planned to do and that is a terrible way to start your day. This post is about a few tools, tips and techniques I use to prevent snoozing.

Tip #1: Sleep well

This is generally easier said done but there’s no way around it. You MUST get enough sleep. Otherwise, sooner or later your will power will get weaker and weaker. Eventually you’ll succumb to the sweet temptation of more sleep.

Tip #2: Place the alarm away from your bed

This way when your alarm (most likely your phone) goes off you have to make a deliberate attempt to get up and turn it off. If you have to get out of the bed you’re more likely to not to get back to it straight away.

Tip #3: Use multiple alarms with different sounds

It gets easier to wake up if you can surprise yourself! Human beings are so good at adapting to every condition we very easily start getting used and ignore the same alarm sound going off at the exact same time every day. I find it useful to change the alarm times and sounds every now and then.

Tip #4: Use Apple Watch

After Apple Watch Series 4 was released I got myself one.

I’m not sure if it’s worth the cost but when it comes to waking up a little vibration on your wrist can do miracles apparently!

When you have it pair with your iPhone, by default you can stop the alarms from your watch. This may be a nice convenience feature in some cases, but when it comes to waking up we are trying to make it as hard as possible for ourselves to turn the alarms off.

My trick is:

First I disable “Push alerts from iPhone” in the Watch app.

Then I create a separate alarm on watch for the same time.

This way I get 2 alarms at the same time. It’s easy to stop the watch as it’s within my arm’s reach. While the haptic feedback of the watch wakes me up the alarm on the phone also goes off. Now I have to physically get out of the bed to stop that one as well.

Tip #5: Use Alexa

Another gizmo to set an alarm is Alexa but you can do much more than just that with Routines.

Tip #5.1: Play a playlist

This tip requires Spotify Premium subscription.

First, create yourself a nice, loud and heavy playlist of “waking up” music. I prefer energetic Heavy Metal songs from Lamb of God and Slayer. The trick here is to play a random song every morning. Similar to Tip #3, the same song every morning becomes very boring very quickly. But having a random one keeps you surprised every morning. I use this command to play my playlist in shuffle mode:

Shuffle Playlist '{Playlist name}'

Tip #5.2: Turn the lights on

A good sleep tip is to keep your bedroom as dark as possible. That’s why I have all black curtains in my room and it’s quite dark. The downside is it’s so good for sleep it makes waking up even harder!

That’s why I bought myself a Philips Hue smart bulb and as part of my waking up routine Alexa turns it on along with playing the Spotify playlist.

This is what my routine looks like:

Conclusion

For me snoozing is a cardinal sin so I’m always on the lookout for improving my arsenal to fight against snoozing. Hope you find something useful in this post too. If you have tips on your own feel free to leave a comment.

Resources

dockerdevops github, backup

A while back I created a PowerShell script to backup my GitHub account and blogged about it here. It’s working fine but it requires some manual installation and setup and I didn’t want to do that every time I needed to deploy it to a new machine. That’s why I decided to Dockerize my script so that everything required can come in an image pre-installed.

TL;DR:

  • There’s a Powershell script that allows you to back up your GitHub account including private repositories here: Source Code
  • There’s a Docker image that encapsulates the same script which can be found here: Docker Image
  • Below are my notes on Docker that I’ve been taking while working on Docker-related projects. Proceed if are interested in some random tidbits about Docker.

Lessons Learned on Docker

  • Shortcut to leave container without stopping it: Ctrl P + Ctrl Q

  • Build a new image from the contents of the current folder

      docker image build -t {image_name} .
    
  • Every RUN command creates a new layer in the image. Image layers are read-only.

  • Connect to an already running container:

      docker attach {container id or name}
    
  • Save a running container as an image:

      docker commit -p 78727078a04b container1
    
  • Remove image

      docker rmi {image name}
    

    This requires the image doesn’t have any containers created off of it. To delete multiple images based on name:

      docker rmi $(docker images | grep 'imagename')
    
  • List running containers

      docker container ls
    
  • To list all containers including the stopped ones:

      docker ps -a
    
  • Delete all stopped containers

      docker container prune
    
  • To delete all unused containers, images, volumes, networks:

      docker system prune
    
  • Copy files to and from a container

      docker cp foo.txt mycontainer:/foo.txt
      docker cp mycontainer:/foo.txt foo.txt
    
  • To overwrite the entrypoint and get an interactive shell

      docker run -it --entrypoint "/bin/sh" {image name}
    
  • Tip to quickly operate on images/containers: Just enter the first few letters of the image/container. For example if your docker ps -a returns something like this

      1184d20ee824        b2789ef1b26a                  "/bin/sh -c 'ssh-k..."   18 hours ago        Exited (1) 46 seconds ago                         happy_saha
      7823f76352e3        github-backup-04              "/bin/sh"                18 hours ago        Exited (255) 21 minutes ago                       objective_thompson
    

    you can start the first container by entering

      docker start 11
    

    This is of course provided that there aren’t any other containers whose ID start with 11. So no need to enter the full ID as long as the beginning is unique.

  • To get detailed info about an object

      docker inspect {object id}
    

    This returns all the details. If you interested in specific details you can tailor the output by using –format option. For example the following only returns the LogPath for the container:

    	
        docker inspect --format '{{ .LogPath  }}'  {container id}
    	
    
  • To get the logs of the container:

      docker logs --details --timestamps  {container id}
    
  • Docker for Mac actually runs inside a Linux VM. All docker data is stored inside a file called Docker.qcow2. The paths that are returned are relative paths in this VM. For instance if you inspect the LogPath of a container it would look something like

      /var/lib/docker/containers/{container-id}/{container-id}-json.log
    

    But if you check your host machine, there is no /var/lib/docker folder.

    In Docker preferences it shows where the disk image is located:

    This command let me to go into VM

      screen  ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
    

    Then I was able to navigate to /var/lib/docker and peek inside the volumes where the data is persisted. This virtualization does not exist in Linux and you can view everything on the host machine straight away.

  • Enter a running container (Docker 1.3+):

      docker exec -it {container-id} bash
    
  • Copy an image from one host to another: Export vs Save

    Save, saves a non-running container image to a file:

      docker save -o <save image to path> <image name>
      docker load -i <path to image tar file>
    

    Export, saves a container’s running or paused instance to a file

      docker export {container-id} | gzip > {tar file path}
      docker import {tar file path}
    

Resources