This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "net/http" | |
| "github.com/go-chi/chi" | |
| "github.com/gorilla/mux" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "os" | |
| "github.com/klauspost/reedsolomon" | |
| ) | |
| // You can use erasure encoding to; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "crypto/aes" | |
| "crypto/cipher" | |
| "crypto/rand" | |
| "crypto/sha256" | |
| "encoding/base64" | |
| "errors" | |
| "fmt" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "context" | |
| "database/sql" | |
| "database/sql/driver" | |
| "fmt" | |
| "path" | |
| "sync" | |
| "sync/atomic" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // file: main_test.go | |
| package main | |
| import ( | |
| "math/rand" | |
| "sync" | |
| "testing" | |
| "time" | |
| gomock "github.com/golang/mock/gomock" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <style> | |
| table, th, td { | |
| border:1px solid; | |
| } | |
| </style> | |
| <body> | |
| <h2>A basic HTML table</h2> | |
| <table style="width:100%"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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/sites/default/files/2024-10/EPRA%20Energy%20and%20Petroleum%20Statistics%20Report%20FY%202023-2024_2.pdf | |
| peak_demand_for_electricity_in_year_2020 = 1880 # megawatt. This was in july 2020 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "testing" | |
| "pgregory.net/rapid" | |
| ) | |
| // Sum adds two numbers. | |
| func Sum(a, b int64) (total int64) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 | |
| price_per_kwh = 33 # kes per unit | |
| consumption_per_month = int(monthly_kplc_cost/price_per_kwh) # kWh | |
| assert consumption_per_month == 151 # kwh | |
| consumption_per_month = 150 * 1000 # watt-hours |