Skip to content

Instantly share code, notes, and snippets.

RFCs, ADRs, and radar

Hello all!

Thanks for attending this 6th Hublo Growth! 🪴

On the menu today:

  • RFCs
  • ADRs
  • Radar
@ValentinMouret
ValentinMouret / solar_flux.py
Created June 19, 2023 21:52
Program which plots the solar flux given some parameters
import math
import matplotlib.pyplot as plt
def calculate_solar_flux(latitude, longitude, panel_orientation, panel_tilt, hour, day_of_year):
# Convertit tous les angles en radians
latitude = math.radians(latitude)
panel_orientation = math.radians(panel_orientation)
panel_tilt = math.radians(panel_tilt)
declination = math.radians(23.45 * math.sin(2 * math.pi * (day_of_year - 81) / 365.0))
hour_angle = math.radians(15 * (12 - hour))
cat /Users/valentinmouret/Desktop/users.csv \
| psql -c "
begin;
create temp table batch_user (
id text primary key,
document jsonb not null
);
-- By beginning a transaction, you ensure
-- that you won't break anything.
-- You can always rollback.
begin;
create temp table batch_user (
 -- Enforcing a primary key slows down the processing
 -- but it helps you making sure you don't have duplicates
 -- in your batch.
 id text primary key,
for id, document in csv:
 connection.execute(
  """
insert into user
 (id, email)
  values (%s, ($s::jsonb)->>'email');
""",
[id, document],
 )
id document
c4ca4238a0b923820dcc509a6f75849b {"email": "foo@bar.com"}
c81e728d9d4c2f636f067f89cc14862c {"email": "alice@bob.com"}
insert into user
  (id, email)
  values ('c4ca4238a0b923820dcc509a6f75849b', 'foo@bar.com'),
  ('c81e728d9d4c2f636f067f89cc14862c', 'alice@bob.org');
create table user (
 id text primary key,
 email text not null
);
alter table firestore.collection
add column author text generated always as (document->>'author') stored;
create index firestore_collection_author_idx
on firestore.collection (author);
create table users (
name text primary key,
age int not null,
is_adult boolean generated always as (age >= 18) stored
);
insert into users
(name, age)
values ('Zola', 54),
('Rimbaud', 8);