Hello World

A sample go program is show here.

package main

import "fmt"

func main() {
  message := greetMe("world")
  fmt.Println(message)
}

func greetMe(name string) string {
  return "Hello, " + name + "!"
}

Run the program as below:

$ go run hello.go
Variables

Normal Declaration:

var msg string
msg = "Hello"

Shortcut:

msg := "Hello"
Constants
const Phi = 1.618
Introduction

SASS is a styling framework which sits on top of CSS, which allows you to use loops, variables …

Every css file is a valid scss file (i.e. if you have a bunch of css files already you can simply convert them to .scss files to get started).

Installation on Mac

SASS is written in Ruby, hence you need to download Ruby to use SASS. The two programmes required to use SASS are Ruby and Ruby Gems (a package manager for Ruby).

On a Mac both Ruby and Ruby Gems are pre-installed. To check these are already installed run the below code on the terminal and if they return a version number you are ready to install SASS.

ruby -v
gem -v

Follow the SASS Install instruction to install SASS. Then check it has worked by running sass --version.

Issues (2022-01-18): I also had to install developer tools on the mac by running xcode-select --install

Using SCSS

Worth noting that SCSS and SASS are a slightly different syntax but can be used for the exact same things. I prefer SCSS since any .css file is a valid .scss file.

To compile your scss files into css use the following in the terminal.

sass --watch <NAME_OF_FOLDER> (i.e. style)

Then import the resulting .css file into your html document.

Strings
str := "Hello"

Multiline string

str := `Multiline
string`
Numbers

Typical types

num := 3          // int
num := 3.         // float64
num := 3 + 4i     // complex128
num := byte('a')  // byte (alias for uint8)

Other Types

var u uint = 7        // uint (unsigned)
var p float32 = 22.7  // 32-bit float
Arrays
// var numbers [5]int
numbers := [...]int{0, 0, 0, 0, 0}
Pointers
func main () {
  b := *getPointer()
  fmt.Println("Value is", b)
func getPointer () (myPointer *int) {
  a := 234
  return &a
a := new(int)
*a = 234

Pointers point to a memory location of a variable. Go is fully garbage-collected.

Type Conversion
i := 2
f := float64(i)
u := uint(i)
Slice
slice := []int{2, 3, 4}
slice := []byte("Hello")
Variables

Variables are intuitive as in any other programming language. The syntax for variables is like the below.

$my-color = "blue"

.my_class {
  color: $my-color;
}
Nesting

This is also intuitive but a very useful feature of scss. You can nest css classes. This is much more readable when you have several nested elements.

main article p {
  color: yellow
}

scss equivelant:

main {
  article {
    p {
      color: yellow;
    }
  }
}
Partials and Imports

You can create a partial in scss by naming your file with a leading _ (i.e. _header.scss). Then import the file with:

@import "_header"; /* relative link to file */

header {
  color: red; /* overrides the code inside _header.scss */
}
Mixins

These are reusable components which when created can be used within your css elements. You can also include parameters. (These are basically css functions).

@mixin fancy-border($size: 1px, $color:black) {
  border $size dashed $color;
  border-radius: 5px;
}

header {
  @include fancy-border(10px, blue);
  background-color: yellow;
}
Extends and Inheritance

Extends can be used to inherit all the parameters in a class to another. The key difference between extends and mixins is that with extends you can use the original class which you extend from in your html. This is like building a class on top of another class in python (i.e. class MyClass2(MyClass1)).

.message {
  font-size: 20px;
  border: 1px solid black;
}

.warning {
  @extend .message;
  color: yellow;
}
Operators

In css you can use operators like *2 or /2.

$base-size: 20px;
$base-color: red;

p {
  font-size: $base-size;
  color: $base-color;
}
button {
  font-size: $base-size * 2;
  background-color: $base-color - 200; /* 200 shades lighter */
}
Conditionals

Basically just if-else statements. The following code makes the color of the text in the header to change based on the size of the page.

@mixin text-style($size) {
  font-size: $size;
  @if $size > 20px {
    color: blue;
  } @elseif $size == 20px {
    color: red;
  } @else {
    color: green;
  }
}

header {
  @include text-style(30px);
}
Condition
if day == "sunday" || day == "saturday" {
  rest()
} else if day == "monday" && isTired() {
  groan()
} else {
  work()
}
if _, err := doThing(); err != nil {
  fmt.Println("Uh oh")
Switch
switch day {
  case "sunday":
    // cases don't "fall through" by default!
    fallthrough

  case "saturday":
    rest()

  default:
    work()
}
Loop
for count := 0; count <= 10; count++ {
  fmt.Println("My counter is at", count)
}
entry := []string{"Jack","John","Jones"}
for i, val := range entry {
  fmt.Printf("At position %d, the character %s is present\n", i, val)
n := 0
x := 42
for n != x {
  n := guess()
}
Condition
if day == "sunday" || day == "saturday" {
  rest()
} else if day == "monday" && isTired() {
  groan()
} else {
  work()
}
if _, err := doThing(); err != nil {
  fmt.Println("Uh oh")
Variable
NAME="John"
echo $NAME
echo "$NAME"
echo "${NAME}
Condition
if [[ -z "$string" ]]; then
  echo "String is empty"
elif [[ -n "$string" ]]; then
  echo "String is not empty"
fi
Useful Resources
Workflows

DBT saves artifacts when jobs are run which allows for creating powerful workflows. The states of commands are saved as artifacts. For example, the below code will reference the status of the data’s freshness and only build models that are “fresh”.

# Command step order
dbt source freshness
dbt build --select source_status:fresher+
Delete an Instance

By default Cloud SQL instances are created with deletion protection. To delete an instance you must first remove deletion protection using the gcloud cli. Run the following code in gcloud with your instance name to delete a Cloud SQL instance.

gcloud sql instances patch [INSTANCE_NAME] --no-deletion-protection
gcloud sql instances delete [INSTANCE_NAME]