Archive

Archive for December, 2018

Designing Well-Structured REST APIs with Flask-RestPlus: Part 1

December 11, 2018 Leave a comment

This is the first part of a two-part series. In this post, I will introduce Flask-RestPlus and demonstrate how to start organising APIs around its simple REST-based conventions. Next time, I will address the topic of request/response marshalling (serialisation) and validation.

https://preslav.me/2018/12/02/designing-well-structured-rest-apis-with-flask-restplus-part-1/

Advertisements
Categories: python Tags:

5 Lessons Learned From Writing Over 300,000 Lines of Infrastructure Code

December 10, 2018 Leave a comment

https://blog.gruntwork.io/5-lessons-learned-from-writing-over-300-000-lines-of-infrastructure-code-36ba7fadeac1

Categories: Interesting

pip – ImportError: cannot import name main

December 7, 2018 Leave a comment

Problem:
Getting above error when running pip

ubuntu@ubuntu-xenial:~$ pip install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 646kB/s 
Installing collected packages: pip
Successfully installed pip-8.1.1
You are using pip version 8.1.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.


ubuntu@ubuntu-xenial:~$ pip install --upgrade pip
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main

Solution:

ubuntu@ubuntu-xenial:~$ python -m pip install -U pip
Requirement already up-to-date: pip in ./.local/lib/python2.7/site-packages (18.1)

Source:
https://stackoverflow.com/questions/28210269/importerror-cannot-import-name-main-when-running-pip-version-command-in-windo

Categories: python

Invalid value for field ‘resource.disks[0].initializeParams.sourceImage’

December 6, 2018 Leave a comment

Problem:
You ran (from https://github.com/kelseyhightower/intro-to-kubernetes-workshop/blob/master/labs/install-gce-client-tools.md)

$ gcloud compute instances create workshop-test \
 --image-project coreos-cloud \
 --image coreos-stable-835-12-0-v20160202 \
 --boot-disk-size 200GB \
 --machine-type n1-standard-1 \
 --can-ip-forward \
 --scopes compute-rw

And get the following error

– Invalid value for field ‘resource.disks[0].initializeParams.sourceImage’: ‘https://www.googleapis.com/compute/v1/projects/coreos-cloud/global/images/coreos-stable-835-12-0-v20160202&#8217;. The referenced image resource cannot be found.

Solution:
The image being referenced does not exist. Get the list of images and pick the correct one.

$ gcloud compute images list --uri | less

$ gcloud compute instances create workshop-test \
 --image-project coreos-cloud \
 --image coreos-stable-1911-4-0-v20181127 \
 --boot-disk-size 200GB \
 --machine-type n1-standard-1 \
 --can-ip-forward \
 --scopes compute-rw
Created [https://www.googleapis.com/compute/v1/projects/ktinga-hallway-224527/zones/us-central1-f/instances/workshop-test].
NAME           ZONE           MACHINE_TYPE   PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP     STATUS
workshop-test  us-central1-f  n1-standard-1               10.128.0.2   35.184.123.230  RUNNING

Source:
https://github.com/docker/machine/issues/3904

Categories: gcloud Tags: ,

Reinstalling minikube

December 5, 2018 Leave a comment

Problem:
How to reinstall minikube

Solution:

1. Stop it if it was running

$ minikube stop

2. Delete the VM in Virtualbox
3. Delete the .minikube folder

$ rm -rf ~/.minikube

4. Reinstall it if need be. Follow install instructions -> https://kubernetes.io/docs/setup/minikube/

Source:
Troubleshooting annoying issues with minikube

Categories: kubernetes Tags:

ALE (Asynchronous Lint Engine)

December 4, 2018 Leave a comment

ALE (Asynchronous Lint Engine) is a plugin for providing linting in NeoVim 0.2.0+ and Vim 8 while you edit your text files, and acts as a Vim Language Server Protocol client.

ALE makes use of NeoVim and Vim 8 job control functions and timers to run linters on the contents of text buffers and return errors as text is changed in Vim. This allows for displaying warnings and errors in files being edited in Vim before files have been saved back to a filesystem.

In other words, this plugin allows you to lint while you type.

https://github.com/w0rp/ale

Categories: vim Tags: ,

How can I change the author name / email of a commit?

December 3, 2018 Leave a comment

Problem:
I needed to change the email address for multiple commits.

Solution:
Followed the steps under this section in the source.

Using Interactive Rebase

Interactive Rebase is the Swiss Army Knife of tools in Git: it allows you to do and change almost anything. However, being as powerful as it is, this also means you can very easily shoot yourself in the foot. Use it with care (and possibly read up on it)!

Source:
https://www.git-tower.com/learn/git/faq/change-author-name-email

Categories: git, Interesting Tags: