Create Image on GCP

Here’s the command to create an image from an existing VM instance. You can create an image from disks, snapshots, images or from a cloud storage file. You can use images you built to launch and restore VM instances, as well as create Instance Templates.

gcloud compute --project=your-project images create your-server --source-disk=your-server --source-disk-zone=us-central1-c

Take A GCP Snapshot

Here’s the gcloud command to create a snapshot of your GCP instance.

gcloud compute disks snapshot your-server \
--snapshot-names=your-server-180808 \
--project=your-project \
--zone=us-central1-c

Cloning A GCP Repo

Here are the steps on how to clone a Google Cloud Platform (GCP) repository. This is assuming you already installed Google Cloud SDK.

gcloud init
gcloud source repos clone name_of_repo --project=project_name
cd name_of_repo
git commit -a -m "your comment"
git push -u origin master

Git Diff

When working with version control, sometimes you would like to know what files were committed locally vs what’s on the master origin repository. One way to know the difference is to use the git diff or the git log commands. Here are the commands to check the differences between the local and master origin repositories. Diff is better in my opinion since it actually displays the code changes instead of just displaying the commit ID.

$ git diff origin/master..HEAD
$ git log origin/master..HEAD

URL Encode

If you need to special characters encoded in a URL, these sites really come handy. Why is there a need to encode? URLs accepts only alphanumeric characters and a limited number of special characters. For example, : and / are common characters you’ll find in URLs. Meanwhile spaces are not allowed, but instead are represented as %20 when encoded. There are other special characters that will need to be encoded.

Here are a couple of sites to help you encode:

https://www.urlencoder.org/
https://www.url-encode-decode.com/