Skip to content

Instantly share code, notes, and snippets.

View komuw's full-sized avatar

Komu Wairagu komuw

View GitHub Profile
@komuw
komuw / spending.py
Last active November 5, 2024 19:08
cost/spending of public primary, jss and secondary education in kenya
# we are going to try estimate the amount of money the govt(ahem, taxpayer) spends per public school student per year/term.
# We are only interested in the figures for students in PUBLIC primary, jss AND secondary schools.
# All the figures here come from the 2024/25 supplementary estimates I.
# see: https://mwangocapital.com/wp-content/uploads/2024/07/fy-24-25-supplementary-1-.pdf
# aka, the one that was sent to parliament after the 2024/25 finance bill was rejected.
# Number of learners.
# We are only interested in primary, jss & secondary school figures.
# See page 221 of the supplementary estimates.
learners_in_public_primary_sch = 6_450_133 # 6million
@komuw
komuw / guide.txt
Last active October 2, 2024 11:39
Book summary: Finally Focussed by Dr. James Greenblatt MD.
Book: Finally Focussed by Dr. James Greenblatt MD.
Checkout: https://examine.com/ , no ads, non-industry affliated review of supplements backed by research
Checkout: https://consumerlab.com , no ads, non-industry affliated review of supplements backed by research
Checkout: https://www.webmd.com/vitamins/index
Nutrient Reference Value(NRV): are used to express the nutritional value of a food product as a percentage of the daily recommended intake for an average adult. It is by the European Food Safety Authority.
A. Magnesium/vitamin b6 guide.
1. Mg(glycinate,citrate,gluconate,l-threonate, but NOT oxide). Under 6yrs: 10mg daily in liquid form.
Liquid ionic magnesium from New beginnings co.
@komuw
komuw / price_of_solar_panel.py
Last active February 29, 2024 11:18
price of solar
# How many units of KPLC do you use per month?
# Go to https://www.stimatracker.com/, click on `prepaid`, then enter amount in KES you use per month.
# Click `calculate`, it will give you your consumption in kwh. Mine is KES 5000, which give ~150kwh
monthly_kplc_cost = 5000 # KES
yearly_kplc_cost = monthly_kplc_cost * 12 # KES
consumption_per_month = 150 # kWh
consumption_per_month = 150 * 1000 # watt-hours
monthly_energy_production_of_solar_panel = (solar_panel_rating_in_watts * number_of_hrs_of_sunlight * solar_panel_efficiency_factor) * 30
@komuw
komuw / fuzz_property_test.go
Last active September 4, 2024 07:47
Golang fuzz testing and also property-based testing.
package main
import (
"testing"
"pgregory.net/rapid"
)
// Sum adds two numbers.
func Sum(a, b int64) (total int64) {
@komuw
komuw / kenya_electricity_power.py
Last active September 8, 2024 09:09
kenya electricity power back of envelope stats
# These statistics, figures and projections are back of the envelope
# see; https://en.wikipedia.org/wiki/Back-of-the-envelope_calculation.
# Do not rely on them for serious matters.
# But they should mostly be relatively accurate.
import math
# According to EPRA(Energy and Petroleum Regulatory Authority)
# See: https://www.epra.go.ke/wp-content/uploads/2023/01/ABRIDGED-KPLC-TARIFF-2023.pdf
peak_demand_for_electricity_in_year_2020 = 1880 # megawatt. This was in july 2020
@komuw
komuw / hey.html
Created November 10, 2023 14:06
nested html table
<!DOCTYPE html>
<html>
<style>
table, th, td {
border:1px solid;
}
</style>
<body>
<h2>A basic HTML table</h2>
<table style="width:100%">
@komuw
komuw / fixed_main_test.go
Last active February 20, 2024 14:34
It's hard to use gomock when there are goroutines involved. gomock sometimes expects them to be called and sometimes it doesn't
// file: main_test.go
package main
import (
"math/rand"
"sync"
"testing"
"time"
gomock "github.com/golang/mock/gomock"
@komuw
komuw / a_sqlite.go
Last active April 19, 2024 06:53
golang and sqlite
package main
import (
"context"
"database/sql"
"database/sql/driver"
"fmt"
"path"
"sync"
"sync/atomic"
@komuw
komuw / fake_crd.yaml
Created November 16, 2022 17:26
fake crd status/health
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
# name must match the spec fields below, and be in the form: <plural>.<group>
name: komucrontabs.stable.example.com
spec:
# group name to use for REST API: /apis/<group>/<version>
group: stable.example.com
# list of versions supported by this CustomResourceDefinition
versions:
@komuw
komuw / encrypt_decrypt.go
Last active July 6, 2022 19:32
encrypt and decrypt in Go
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"crypto/sha256"
"encoding/base64"
"errors"
"fmt"