This post is focused on different ways to interact with JSON with Python using json:

https://docs.python.org/3/library/json.html.

We’ll look at their limitations, run time errors, and etc., with sample code. We start from a basic type Dictionary and eventually discussed a solution for working with complex Python objects.

Dictionary

Python and the json module is working extremely well with dictionaries. The following is for serializing and deserializing a Python dictionary:

Code:

import jsonstudent = {
"first_name": "Jake",
"last_name": "Doyle"
}
json_data = json.dumps(student, indent=2)
print(json_data)
print(json.loads(json_data))

Output:

{
"first_name": "Jake",
"last_name": "Doyle"
}
{'first_name': 'Jake', 'last_name': 'Doyle'}

Object

However, if we create…


Tap into the power of Google Drive

Photo by Stephen Frank on Unsplash

Google APIs are a huge umbrella. Check out the almost 200 entries from the Google API explorer. Among all these APIs, some of popular ones include: Google Drive, Gmail, Cloud Datastore, Google Cloud Storage, etc. Today, let’s take a look at what it takes to integrate the Google Drive API into a Flutter app.

There are many interesting aspect of Google Drive API. But one of the most interesting ones that I find are that it gives cloud storage for your user data without having to actually build, maintain, and pay for cloud storage. …


There are plenty of beginner tutorials about building TODO apps, recipe apps, habit tracker apps, etc. Most of them focus on building UI, which undoubtedly is one of the most important topics for a mobile application. However, nowadays, most interesting apps also contain a server-side component.


UIStackView simplifies the view layout by reducing the number of constraints

Photo by Annie Spratt on Unsplash

Introduction

UIStackView is one of the most important and powerful UIKit components introduced in iOS 9. It is so powerful and elegant that it really speeds up a lot of us pushing to drop support for iOS 8.

For people that work with Auto Layout a lot, you will know that it is not particularly fun and easy to create NSLayoutConstraints. Since each view on a 2D screen has four degrees of freedom, it means that, in general, we would have to create at least four constraints for each view.

So, back to the introduction of stack view, was it that…


Python is known to be good for data visualization. There are many tools in Python enabling it to do so: matplotlib, pygal, Seaborn, Plotly, etc. Among these, matplotlib is probably the most widely used one. On one hand, it offers a lot of flexibilities; on the other hand, it is also very low-level and may not the most straight forward to use. There are a lot of articles explaining how to do 2d plotting with matplotlib already. In this post, we will focus more on plotting in 3d.

You can simply read through this as it. But to get the…


In this block post, we’ll package applications with Docker containers, and then deploy them with Kubernete in a local minikube cluster. We’ll cover some Kubernete concepts such as Pod, Deployment, Service, etc. Source code is published here.

This is a semi-rerun of an older blog Developing Microservices with minikube. If you are into Typescript and want some step-by-step level of details, check that out instead. We focus more on Kubenetes and Docker instead of building applications here.

There are 3 apps: auth, gateway, and books. They are implemented in 3 different ways.

  • Typescript + express.js
  • Scala + finch
  • Python +…

This is a follow up for DNS configurations for dev environment (Part 1), with some useful troubleshooting tips and tricks here.

System DNS configuration

View the DNS configuration used by this system. It is expected to see the following.

$ scutil --dns...
resolver #8
domain : local.zone
nameserver[0] : 127.0.0.1
flags : Request A records, Request AAAA records
reach : 0x00030002 (Reachable,Local Address,Directly Reachable Address)

System Log

Check the system log for errors. In this case, dnsmasq is in a reboot loop.

$ tail -f /var/log/system.logMay 19 22:06:51 L10019 com.apple.xpc.launchd[1] (homebrew.mxcl.dnsmasq[16346]): Service exited with abnormal code: 3 May 19 22:06:51 L10019 com.apple.xpc.launchd[1] (homebrew.mxcl.dnsmasq)…

The goal of this blog post is to forward requests to *.local.zone to 127.0.0.1 for local development purposes. local.zone can be any domain in general.

Using /etc/hosts

A simple solution is to add entries in /etc/hosts. This file overwrites the DNS resolving. Whatever is specified in this file, it will be automatically redirected to the corresponding IP address. For example, this is a default etc/hosts:

127.0.0.1       localhost
255.255.255.255 broadcasthost
::1 localhost

In this case, localhost will be redirected to 127.0.0.1. The only problem with this approach is that it doesn’t support wildcard matching. …


Within the last 5 years, Kubernetes has received 2k+ contributors and 50k+ stars on Github 🌟⭐.

Number of stars overtime https://github.com/kubernetes/kubernetes

This blog post will go through some of the basics behind managing micro-services using Kubernetes. We’ll be using minikube, which allows us to run Kubernetes locally.

For the purpose of this blog, we’ll only create 3 services: auth_svc, gateway_svc, books_svc.

  • auth_svc is responsible for user authentication.
  • gateway_svc handles all requests from the client.
  • books_svc handles book lookup by id.

A user will make a request (with a book_id) to gateway_svc, which will then check the forward the auth token from the request to auth_svc…


Introduction

This step-by-step guide shows how to install Apache Kafka within a Ubuntu docker image. The reason why we choose a docker image here is so that we have a clean environment to work with.

Install Docker

To begin with, make sure you have Docker installed properly on your machine:

$ docker --versionDocker version 18.09.2, build 6247962

If you don’t have Docker installed, you download & install it from https://docs.docker.com/.

Ubuntu Container

Ubuntu docker image is available at the Docker Hub https://hub.docker.com/_/ubuntu. We’ll use the current latest version for this tutorial, which is 18.04. …

Yuchen Zhong

I work as an Engineer in the day time. At night and over the weekend, I play with various stuff and write about them, either related or not related to work.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store