Skip to content

Instantly share code, notes, and snippets.

View noamt's full-sized avatar

Noam Y. Tenne noamt

View GitHub Profile
@noamt
noamt / power_assert_outcome.py
Created June 29, 2021 09:49
For the Medium post "Python Power Assertions with Nimoy"
AssertionError: Assertion failed:
sc.val['d'] == 'f'
| | |
| e False
{'d': 'e'}
@noamt
noamt / power_assertion.py
Created June 29, 2021 09:47
For the Medium post "Python Power Assertions with Nimoy"
class SomeClass:
def __init__(self):
self.val = {'d': 'e'}
def __str__(self):
return str(self.val)
sc = SomeClass()
sc.val['d'] == 'f'
@noamt
noamt / hamcrest_output
Created June 29, 2021 09:32
For the Medium post "Python Power Assertions with Nimoy"
Expected: "There's a small difference"
but: was "There's a huge difference"
Hint:
- There's a huge difference
? ^^^^
+ There's a small difference
? ^^^^^
@noamt
noamt / example.go
Created June 3, 2020 09:42
For the Medium post "Find the first day of the week with Go"
package main
import (
"github.com/noamt/go-cldr/supplemental"
"golang.org/x/text/language"
)
func main() {
tag, _ := language.Parse("en-US")
region, _ := tag.Region()
@noamt
noamt / supplementalData.xml
Created June 3, 2020 09:28
For the Medium post "Find the first day of the week with Go"
<firstDay day="mon" territories="
001
AD AI AL AM AN AR AT AX AZ
BA BE BG BM BN BY
CH CL CM CR CY CZ
DE DK
EC EE ES
FI FJ FO FR
GB GE GF GP GR
HR HU
@noamt
noamt / reachout_ssl_test.go
Created February 18, 2020 16:20
For blog post "Simulating SSL outages with Go"
package reachout_test
import (
"net/http"
"net/http/httptest"
"os"
"testing"
)
func Test_ReachOut_SSLExpired(t *testing.T) {
@noamt
noamt / reachout_ssl_cert_test.go
Created February 18, 2020 16:15
For blog post "Simulating SSL outages with Go"
func expiredSSLCertificate() (*tls.Certificate, error) {
priv, err := ecdsa.GenerateKey(elliptic.P521(), rand.Reader)
if err != nil {
return nil, fmt.Errorf("failed to generate private key: %w", err)
}
template := x509.Certificate{
SerialNumber: big.NewInt(1),
Subject: pkix.Name{
Organization: []string{"Acme Co"},
},
@noamt
noamt / reachout_test.go
Created February 18, 2020 15:58
For blog post "Simulating SSL outages with Go"
package reachout_test
import (
"net/http"
"net/http/httptest"
"os"
"testing"
)
func Test_ReachOut(t *testing.T) {
@noamt
noamt / reachout.go
Last active February 18, 2020 15:50
For blog post "Simulating SSL outages with Go"
package reachout
import (
"fmt"
"net/http"
"os"
)
func ReachOut() string {
host := os.Getenv("API_HOST")
@noamt
noamt / replica.tf
Created February 7, 2020 09:25
For blog post "Highly available, read-replicated PostgreSQL with Google CloudSQL and Terraform"
resource "google_sql_database_instance" "read_replica" {
name = "replica-${random_id.db_name_suffix.hex}"
master_instance_name = "${var.project_id}:${google_sql_database_instance.master.name}"
region = "europe-west4"
database_version = "POSTGRES_11"
replica_configuration {
failover_target = false
}