San Jose Parking Garage Data

 

The color scheme follows the same as described in https://www.violet-mica.com/2017/11/09/raspberry-pi-plot-of-temperature-humidity-pressure-data/. Roy.G.Biv. (rainbow) with red as today, orange as yesterday, yellow as the day before that, etc.

It can be seen that the parking garage is EXTREMELY FULL, which is due to Fanime in the San Jose Convention Center this Memorial Day Weekend.

Conversely, see this graph, which clearly serves a business district (or otherwise people who work on weekdays):

It’s completely empty today, Saturday! And the schedule of the weekdays are quite regular, with slightly less cars throughout the day on Friday but still following the general day pattern of the other two recorded weekdays.

Here, you can see that first the Convention Center Garage filled (notice the plateau), then the Second San Carlos Garage filled, and now people are working on filling the Market San Pedro Square Garage! (However, also note that Fourth Street Garage is reporting usage of a negative number of parking spaces. Since the API returns the number of spaces available in the garage, the data shown here are the number of spaces available in the garage subtracted from the total available capacity of the garage. So this probably means they under-counted the total capacity of the garage, or reported a number of available spaces greater than actual total number of spaces available in the garage.)

I started recording San Jose parking garage data on 2018-05-22. This data is publicly available for free from https://data.sanjoseca.gov/developers/. Here is an example of what the data looks like (json format):

{
    "page": "1",
    "rows": [
        {
            "cell": [
                "Fourth Street Garage",
                "Open",
                "324",
                "350"
            ],
            "id": "4"
        },
        {
            "cell": [
                "City Hall Garage",
                "Open",
                "255",
                "302"
            ],
            "id": "8"
        },
        {
            "cell": [
                "Third Street Garage",
                "Open",
                "142",
                "146"
            ],
            "id": "12"
        },
        {
            "cell": [
                "Market San Pedro Square Garage",
                "Open",
                "349",
                "425"
            ],
            "id": "16"
        },
        {
            "cell": [
                "Convention Center Garage",
                "Open",
                "445",
                "510"
            ],
            "id": "20"
        },
        {
            "cell": [
                "Second San Carlos Garage",
                "Open",
                "184",
                "205"
            ],
            "id": "24"
        }
    ],
    "total": 7
}

Numpy Basics

Numpy is a python library for efficiently dealing with arrays. Under the hood, it can leverage C and Fortran to achieve those efficient array operations.

  • It’s important to note that if you want to use numpy for a single element, use np.array([1]) as opposed to np.array(1) or np.uint8(1). Operations on np.uint8 or a scalar np.array (such as np.array(1)) aren’t guaranteed to return a numpy data type or to behave properly:
    • In [35]: type(np.array(10000) * 1000000000000000000000000000000)
      Out[35]: int
      
    • In [36]: a = np.array(10000)
      
      In [37]: a *= 1000000000000000000000000000000
      ---------------------------------------------------------------------------
      TypeError                                 Traceback (most recent call last)
       in ()
      ----> 1 a *= 1000000000000000000000000000000
      
      TypeError: ufunc 'multiply' output (typecode 'O') could not be coerced
      to provided output parameter (typecode 'l') according to the casting rule ''same_kind''
      

Although it’s also important to remember that, under normal operation, you need to deal with overflow. Depending on your application, overflow can be a desirable thing. Here’s an example of overflow:

In [1]: import numpy as np
In [3]: a = np.array([255], dtype=np.uint8)
In [4]: a
Out[4]: array([255], dtype=uint8)
In [5]: a+1
Out[5]: array([0], dtype=uint8)

Instead of 255+1 becoming 256, it became 0, because 255 is the maximum value a uint8 can hold, so when 1 was added to it, all the bits were flipped from 1s to 0s, i.e. from 11111111 to 00000000. uint8: “u” means unsigned, as in no negative numbers; int means integers, as in no decimal places; 8 means 8 bits, as in 8 digits, each of which is either a 0 or a 1.

Internet Security for Everyone

Why you should care: These days, almost everyone uses computers or “smart” phones (or internet-connected toys/refrigerators/thermostats). It’s difficult to avoid them. But everyone should know some basic things when using them, so that you don’t unwittingly give away your passwords, credit card numbers, or let your computer become a zombie in a botnet.

Security things to remember when using computers:
Read more Internet Security for Everyone

Postgresql short-circuit evaluation

The purpose of this post is to demonstrate that Postgres follows short-circuit evaluation. That means, if you are checking two boolean values, if you are seeing if one or the other is true, and the first one is true, then you don’t need to check the second one, because you know the whole statement is true. For example:

true or true: true; when we see “or”, we know that because the first statement was “true”, we don’t need to check the second statement.
true or false: true; same answer as above, for the same reason. this statement is still true even though the second part of the statement is “false”, because the first part is true and it’s joined using “or”.
Read more Postgresql short-circuit evaluation

Git Tricks

Always remember the difference between “log” and “diff”. Log lists commits (optionally showing code changes using -p/--patch), while diff shows the code changes. Log can help you understand changes over time, while diff can help you get a holistic understanding of those changes.

Learning to learn

The first thing to know about git is how to read the manpages. The man pages can be accessed by running these from the command line: “man git”, “man git-diff”, “man git-log”, etc. Note that there is a top-level “git” command (one that doesn’t have “diff”/”log”/etc following it), and that it does have its own man page. It introduces all the git commands and the terminology/syntax.

Git Diff

For example, if you know someone implemented a feature but it took them multiple commits, you can use git-log to find the commit just before the first commit to implement the feature Read more Git Tricks