Things I learned: 2018#17

  • In go an if statement may contain a list of multiple commands - the return value of the last will be used to determine the outcome of that statement. This makes multiple return values compatible with if statements.

    if _, ok = doSomething(); !ok {
          // It failed
    }
    
    • In go the following construct is actually a typecasting that tells the compiler and runtime which concrete implementation of an interface I expect: someVariable.(*expectedType). If the expected concrete implementation is compatible with the true value of the variable then it is returned as the first returned variable. The second returned variable indicates whether or not the operation was successful. In this example token.Method is of the type SigningMethod and SigningMethodHMAC is a concrete implementation of that method: go if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok { return nil, fmt.Errorf("Unexpected signing method: %v", token.Header["alg"]) }
  • Good twisted pair cables use copper for their cores. Copper is fairly expensive however. Therefor cheap cables often use an alloy containing a lot of aluminium. Aluminium is not as conductive and signal-loss will be higher when using long cables. if you are planning on running cables through walls then you are better off buying a high quality cable since replacing it will be a pain. If your want to check a cable, remove the mantle and hold a lighter to it. If the cores burn and disintegrate then it is aluminium. If the core does not burn then it is copper.

  • There is a bug in Virtualbox where VBoxClient --draganddrop will consume 100% CPU on Linux guests because it thinks that every mouse movement is a drag&drop event that needs to be synchronized between host and guest. This slows down machines considerably. Disabling Drag&Drop solves this issue.