[kcdc 2022] level up with co-pilot

Speaker: Rizel Scarlett @blackgirlbytes

For more, see the table of contents

Notes

  • AI pair programmer
  • Not magic
  • Compare to Gmail smart compose – suggests continuations
  • Draws context from comments/code
  • Suggests lines/functions

Open AI

  • Powered by Open AI Codex – translates natural language into code
  • GPT-3 – generative pre-trained tranformer 3 – deep learning to produce human like text
  • Duolingo GPT-3 uses for grammar correction
  • Codex code based
  • Played with https://beta.openai.com/examples – Movie to Emoji and Mood to Color (many others).
  • There is also https://beta.openai.com/playground (if you login) where it can generate code from a comment. Even lets you specify a language
  • Also learned you can paste a hex code into google and have it show you the color

Copilot Labs

  • Hover over suggestion to get more
  • Experimental feature to include an explanation of what code does
  • Plugins – VS Code, JetBrains, Neovim
  • Can choose not to include public code
  • Can do some (human) language translation

Benefits

  • Code faster and clear – good at patterns, syntax (ex: regex) so don’t need to google, write better comments so copilot can give good suggestions
  • Write good docs – in markup
  • Be a better mentor – avoids nervousness of someone watching you type because don’t have to worry about syntax, helps mentor people in languages don’t know
  • Gain context for new concepts – studying for interviews (leetcode), explain new code base, create short demos in new languages as dev advocate

Tips

  • Turn off when writing initial structure. Turn on once have pattern going. Comments not useful at first.
  • Good when writing unit tests.

Cost

  • $10/month
  • Free if open source or student

My take

Rizel has a lot of energy and is very relatable. She also did “group play” with openai early. All of that helped engage the audience. I’ve read about co-pilot but it was really cool to see it and the features/benefits/use cases. I enjoyed seeing her passion for the tool and the examples. I also liked how she avoided it from devolving into an argument about the ethics of co-pilot. Rizel didn’t let the wifi problem throw her. It was unfortunate that the demo didn’t work even though other internet stuff did. [block? too bandwidth heavy?] The code to tweet was cool

For co-pilot, some looks cool. Some of the comments were longer than the code. So in real life, I imagine you wouldn’t use it for everything.

[kcdc 2022] reduce system fragility with terraform

Speaker: Scott McAllister @stmcallister

For more, see the table of contents

Notes

  • Problem: onboarding same thing dozens of time
  • Infrastructure as code – fast to configure/scale, consistent, reduce errors, self documenting
  • AWS CloudFormation, Azure ARM, Terraform and Pulumi in this space. (Pulumi has been rising and is 2)
  • Terraform is declarative, Pulumi is imperative; use existing programming language

Terraform

  • Declarative
  • Open source – most people use this oer enterprise
  • HCL – Hashicorp configuraton language
  • Manage infrastructure – build, change, version, single source of truth
  • No longer use UI; Terraform will overwrite changes
  • Hashicorp maintains Terraform engine

Providers

  • Hashicorp maintains a few large providers (ex: AWS)
  • Everything else run by community or other companies
  • Doc example https://registry.terraform.io/providers/PagerDuty/pagerduty/latest/docs

Flow

  • Practitioner writes infrastructure as code
  • init – takes definitions in directory, downloads providers
  • plan – want to do this so not billed before confirm
  • apply – changes pushed to environments. Runs plan first. Type ”yes” to confirm or use auto approve flag
  • destroy – wipe out everything have
  • Terraform state has data about config – ex; generated id. In JSON format

Good practices

  • Name service what is providing. Ex: ”Checkout API”
  • Version control system
  • Code review
  • Automated testing
  • Put tokens in environment variable rather than hard coding in script

HCL blocks

  • resource – you are going to manage it, create if not present, etc. Convention: providerName_endpoint. Then unique id – like a variable name within terraform. Ex: resource ”pagerduty_user” ”lisa”, Reference as pageruty_user.lisa.id
  • data – like a query. Get data about something that already exists in system. Reference as data.provider_user.id
  • required_providers – downloads binaries when run tf init. Recommend locking into a version or at least a major version

Data types

  • strings
  • numbers
  • [list, of, data]
  • { a: b, c:d } (complex object)

Can play for free: https://github.com/PagerDuty-Samples/pd-populate-dev-account

Q&A

  • Can find syntax and logic errors in plan. Depends on provider
  • Libraries to convert to HCL. Ex: LDAP to HCL

My take

This served as both a good overview and a good review of the basics. I like that it had a lot of code in it. I’m taking the Terraform cert this month so nice timing for me to attend this talk. I really appreciate the link/API to play for free. Testing on AWS is scary :).

[kcdc 2022] calculating your cloud co2e emissions

Speaker: Joel Lord @joel__lord

For more, see the table of contents

Code impact

  • data centers 2% global electricity demand and 3% greenhouse gasses
  • equivalent to irline ndustry
  • planet has SLO – limit to what we can put in it
  • Car 192g/km
  • Domestic fight 255g/km
  • SMS .014g
  • Email 3g [I googled why high. It can be. .3 to 26 depending on how long to read/write]
  • Tweet .2g
  • Googe search .2g
  • Fart – .2g

Factors

  • CPU/GPU – GPU use more energy, but can perform for consistently – 12.4/38.2
  • RAM – always used so more RAM you have, the more energy used – .3 per GB hour
  • DIsk storage – .002 – per GB hour
  • Network Transfer .027 – per GB
  • Other (cooling, lighting, etc)

Formula includes

  • Time
  • PUE (power usage efficiency) – AWS 1.2, GCP 1.1, Azure (1.125). Only GCP publishes number. Others found somewhere. By contast, average is 1.67 including private data farms
  • CI (carbon intensity) – region specific depending on source of power. NY 200g/kWh, Australlia (lots of coal) 880g/kWH, Quebec 14g/kWh
  • Server tier – CPU, RAM, hard drive
  • Utilization – ex: Atlas CLI/management API
  • M30 on US East 1 for 24 hours – 401g CO2e (72K farts)
  • https://github.com/joellord/atlas-co2

Notes

  • GCP has a carbon footprint dashboard to get bar charts with info for your services
  • Reduce energy using
  • Return only top results
  • Llower default quality
  • Don’t autoplay video
  • Use dark mode – less energy for dark pixels
  • Package size matters – use JAM (JavaScript, APIs and markup) stack
  • Derver rendered pages
  • Reduce complexity – data access together should be stored together
  • Green programming language – C, Rust, C++, Java, C#, JS best. TypeScript, PHP, Ruby, Python worse
  • Migrate to the public cloud – they try to reduce costs by saving energy
  • Serverless or autoscaling
  • Cloud region matters – 80x differences
  • Latency may be ok and then can use smaller nodes
  • Pause servers when not in use – ex: weekend
  • Better monitoring – can go to lower tier if needed
  • Leerage XaaS solutions – (anything as a service)
  • Use right tool – ex: do you need a database

My take

A lot of the beginning was about the impacts of climate change. I feel like the audience knew this part and would have liked to get to the part sooner. The comparisons were good and number of farts were fun. I would have liked more examples of the numbers. The end on things you can do was good.