The code and data behind xeiaso.net
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

lume/notes: add go pointer conversion note

Signed-off-by: Xe Iaso <me@xeiaso.net>

+158 -43
+2 -1
.dockerignore
··· 2 2 frontend 3 3 .env 4 4 .git 5 - manifest 5 + manifest 6 + lume
-7
.github/workflows/tigris-push.yml
··· 44 44 path: | 45 45 /home/runner/.cache/deno 46 46 47 - - name: Tailscale 48 - uses: tailscale/github-action@v2 49 - with: 50 - oauth-client-id: ${{ secrets.TAILSCALE_CLIENT_ID }} 51 - oauth-secret: ${{ secrets.TAILSCALE_CLIENT_SECRET }} 52 - tags: tag:ci 53 - 54 47 - name: Build and deploy xesite 55 48 run: | 56 49 go run ./cmd/fabricate-generation
+31 -31
Brewfile.lock.json
··· 618 618 } 619 619 }, 620 620 "flyctl": { 621 - "version": "0.2.114", 621 + "version": "0.2.125", 622 622 "bottle": { 623 623 "rebuild": 0, 624 624 "root_url": "https://ghcr.io/v2/homebrew/core", 625 625 "files": { 626 626 "arm64_sonoma": { 627 627 "cellar": ":any_skip_relocation", 628 - "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:bd5ebc9e5d62ae0bd61fc881e23b905b7c987cedf16f51c36224b798964c76b5", 629 - "sha256": "bd5ebc9e5d62ae0bd61fc881e23b905b7c987cedf16f51c36224b798964c76b5" 628 + "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:54bfeca205000c73e6b4642f78acd49c24abb60e532189ed0549eec31c36f142", 629 + "sha256": "54bfeca205000c73e6b4642f78acd49c24abb60e532189ed0549eec31c36f142" 630 630 }, 631 631 "arm64_ventura": { 632 632 "cellar": ":any_skip_relocation", 633 - "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:bd5ebc9e5d62ae0bd61fc881e23b905b7c987cedf16f51c36224b798964c76b5", 634 - "sha256": "bd5ebc9e5d62ae0bd61fc881e23b905b7c987cedf16f51c36224b798964c76b5" 633 + "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:54bfeca205000c73e6b4642f78acd49c24abb60e532189ed0549eec31c36f142", 634 + "sha256": "54bfeca205000c73e6b4642f78acd49c24abb60e532189ed0549eec31c36f142" 635 635 }, 636 636 "arm64_monterey": { 637 637 "cellar": ":any_skip_relocation", 638 - "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:bd5ebc9e5d62ae0bd61fc881e23b905b7c987cedf16f51c36224b798964c76b5", 639 - "sha256": "bd5ebc9e5d62ae0bd61fc881e23b905b7c987cedf16f51c36224b798964c76b5" 638 + "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:54bfeca205000c73e6b4642f78acd49c24abb60e532189ed0549eec31c36f142", 639 + "sha256": "54bfeca205000c73e6b4642f78acd49c24abb60e532189ed0549eec31c36f142" 640 640 }, 641 641 "sonoma": { 642 642 "cellar": ":any_skip_relocation", 643 - "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:55b2da7831031681b0680295073a382e0306cd8c4a3feac0d81b22b34e05b8fe", 644 - "sha256": "55b2da7831031681b0680295073a382e0306cd8c4a3feac0d81b22b34e05b8fe" 643 + "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:a335cf7168b566f0d7fb67a1f954bdcde0c03df38e49787b5b73efdc5f6acd26", 644 + "sha256": "a335cf7168b566f0d7fb67a1f954bdcde0c03df38e49787b5b73efdc5f6acd26" 645 645 }, 646 646 "ventura": { 647 647 "cellar": ":any_skip_relocation", 648 - "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:55b2da7831031681b0680295073a382e0306cd8c4a3feac0d81b22b34e05b8fe", 649 - "sha256": "55b2da7831031681b0680295073a382e0306cd8c4a3feac0d81b22b34e05b8fe" 648 + "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:a335cf7168b566f0d7fb67a1f954bdcde0c03df38e49787b5b73efdc5f6acd26", 649 + "sha256": "a335cf7168b566f0d7fb67a1f954bdcde0c03df38e49787b5b73efdc5f6acd26" 650 650 }, 651 651 "monterey": { 652 652 "cellar": ":any_skip_relocation", 653 - "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:55b2da7831031681b0680295073a382e0306cd8c4a3feac0d81b22b34e05b8fe", 654 - "sha256": "55b2da7831031681b0680295073a382e0306cd8c4a3feac0d81b22b34e05b8fe" 653 + "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:a335cf7168b566f0d7fb67a1f954bdcde0c03df38e49787b5b73efdc5f6acd26", 654 + "sha256": "a335cf7168b566f0d7fb67a1f954bdcde0c03df38e49787b5b73efdc5f6acd26" 655 655 }, 656 656 "x86_64_linux": { 657 657 "cellar": ":any_skip_relocation", 658 - "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:94fb1a2d402c31465879b6f5d04434a633f1a5b4b02edc0f17784c453bd7b71d", 659 - "sha256": "94fb1a2d402c31465879b6f5d04434a633f1a5b4b02edc0f17784c453bd7b71d" 658 + "url": "https://ghcr.io/v2/homebrew/core/flyctl/blobs/sha256:b61a528c47f2c3712619a73cbbec7d5be15980b5bee0ac712faac559b4c57877", 659 + "sha256": "b61a528c47f2c3712619a73cbbec7d5be15980b5bee0ac712faac559b4c57877" 660 660 } 661 661 } 662 662 } ··· 664 664 "go@1.23": { 665 665 "version": "1.23.0", 666 666 "bottle": { 667 - "rebuild": 0, 667 + "rebuild": 1, 668 668 "root_url": "https://ghcr.io/v2/homebrew/core", 669 669 "files": { 670 670 "arm64_sonoma": { 671 671 "cellar": "/opt/homebrew/Cellar", 672 - "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:9ae04e3063ff69c93dff6e982d93ed8c07114cdd50db418ddbb514c0f3cbb0a2", 673 - "sha256": "9ae04e3063ff69c93dff6e982d93ed8c07114cdd50db418ddbb514c0f3cbb0a2" 672 + "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:5cc408349e666ae1c8ee789d057990f523a0cb8cc51919a913eb0df64e410d43", 673 + "sha256": "5cc408349e666ae1c8ee789d057990f523a0cb8cc51919a913eb0df64e410d43" 674 674 }, 675 675 "arm64_ventura": { 676 676 "cellar": "/opt/homebrew/Cellar", 677 - "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:9ae04e3063ff69c93dff6e982d93ed8c07114cdd50db418ddbb514c0f3cbb0a2", 678 - "sha256": "9ae04e3063ff69c93dff6e982d93ed8c07114cdd50db418ddbb514c0f3cbb0a2" 677 + "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:5cc408349e666ae1c8ee789d057990f523a0cb8cc51919a913eb0df64e410d43", 678 + "sha256": "5cc408349e666ae1c8ee789d057990f523a0cb8cc51919a913eb0df64e410d43" 679 679 }, 680 680 "arm64_monterey": { 681 681 "cellar": "/opt/homebrew/Cellar", 682 - "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:9ae04e3063ff69c93dff6e982d93ed8c07114cdd50db418ddbb514c0f3cbb0a2", 683 - "sha256": "9ae04e3063ff69c93dff6e982d93ed8c07114cdd50db418ddbb514c0f3cbb0a2" 682 + "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:5cc408349e666ae1c8ee789d057990f523a0cb8cc51919a913eb0df64e410d43", 683 + "sha256": "5cc408349e666ae1c8ee789d057990f523a0cb8cc51919a913eb0df64e410d43" 684 684 }, 685 685 "sonoma": { 686 686 "cellar": "/usr/local/Cellar", 687 - "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:78c91083ca44ee58e1eeb70286ead1564f44f570aeba12c5a7a981c059cc28a2", 688 - "sha256": "78c91083ca44ee58e1eeb70286ead1564f44f570aeba12c5a7a981c059cc28a2" 687 + "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:68252d4fc1abb13c66c9ee088c1f97628beecac65b6c1223cf72dd517adab1b1", 688 + "sha256": "68252d4fc1abb13c66c9ee088c1f97628beecac65b6c1223cf72dd517adab1b1" 689 689 }, 690 690 "ventura": { 691 691 "cellar": "/usr/local/Cellar", 692 - "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:78c91083ca44ee58e1eeb70286ead1564f44f570aeba12c5a7a981c059cc28a2", 693 - "sha256": "78c91083ca44ee58e1eeb70286ead1564f44f570aeba12c5a7a981c059cc28a2" 692 + "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:68252d4fc1abb13c66c9ee088c1f97628beecac65b6c1223cf72dd517adab1b1", 693 + "sha256": "68252d4fc1abb13c66c9ee088c1f97628beecac65b6c1223cf72dd517adab1b1" 694 694 }, 695 695 "monterey": { 696 696 "cellar": "/usr/local/Cellar", 697 - "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:78c91083ca44ee58e1eeb70286ead1564f44f570aeba12c5a7a981c059cc28a2", 698 - "sha256": "78c91083ca44ee58e1eeb70286ead1564f44f570aeba12c5a7a981c059cc28a2" 697 + "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:68252d4fc1abb13c66c9ee088c1f97628beecac65b6c1223cf72dd517adab1b1", 698 + "sha256": "68252d4fc1abb13c66c9ee088c1f97628beecac65b6c1223cf72dd517adab1b1" 699 699 }, 700 700 "x86_64_linux": { 701 701 "cellar": "/home/linuxbrew/.linuxbrew/Cellar", 702 - "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:7ce2a2f4ebb0c620f909da574fe88b8abcf09e1c7e6acd6eb5f486a1931697c4", 703 - "sha256": "7ce2a2f4ebb0c620f909da574fe88b8abcf09e1c7e6acd6eb5f486a1931697c4" 702 + "url": "https://ghcr.io/v2/homebrew/core/go/blobs/sha256:8dc5e2fbbb380bd1b1f41b2be7bd1faa61b8d071231d4b193a23f1e6353f28ef", 703 + "sha256": "8dc5e2fbbb380bd1b1f41b2be7bd1faa61b8d071231d4b193a23f1e6353f28ef" 704 704 } 705 705 } 706 706 } ··· 731 731 "GCC": "11.4.0" 732 732 }, 733 733 "Ubuntu 22.04.3 LTS (jammy)": { 734 - "HOMEBREW_VERSION": "4.3.17", 734 + "HOMEBREW_VERSION": "4.3.19", 735 735 "HOMEBREW_PREFIX": "/home/linuxbrew/.linuxbrew", 736 736 "Homebrew/homebrew-core": "api", 737 737 "GCC": "11.4.0"
+5 -4
cmd/fabricate-generation/main.go
··· 29 29 var ( 30 30 bucketName = flag.String("bucket-name", "xesite", "Name of the S3 bucket to upload to") 31 31 githubSHA = flag.String("github-sha", "", "GitHub SHA to use for the site") 32 - miURL = flag.String("mimi-announce-url", "", "Mi url (named mimi-announce-url for historical reasons)") 32 + miURL = flag.String("mimi-announce-url", "", "Mi url") 33 33 patreonSaasProxyURL = flag.String("patreon-saasproxy-url", "http://xesite-patreon-saasproxy.flycast", "URL to use for the patreon saasproxy") 34 34 siteURL = flag.String("site-url", "https://xeiaso.net/", "URL to use for the site") 35 35 ) ··· 52 52 if err != nil { 53 53 log.Fatal(err) 54 54 } 55 + _ = s3c 55 56 56 57 fs, err := lume.New(context.Background(), &lume.Options{ 57 58 Branch: "main", ··· 69 70 70 71 defer fs.Close() 71 72 72 - if err := uploadFolderToS3(context.Background(), s3c, "./var/repo/lume/_site", *bucketName); err != nil { 73 - log.Fatal(err) 74 - } 73 + // if err := uploadFolderToS3(context.Background(), s3c, "./var/repo/lume/_site", *bucketName); err != nil { 74 + // log.Fatal(err) 75 + // } 75 76 } 76 77 77 78 func NewPatreonClient(hc *http.Client) (*patreon.Client, error) {
+22
dhall/jobHistory.dhall
··· 80 80 } 81 81 } 82 82 83 + let xeserv = 84 + Company::{ 85 + , name = "Xeserv" 86 + , url = Some "https://xeserv.us" 87 + , tagline = "Uber for developer marketing consulting" 88 + , location = ottawa 89 + } 90 + 83 91 in [ Job::{ 92 + , company = xeserv 93 + , title = "Chief Executive Officer" 94 + , startDate = "2024-08-30" 95 + , salary = annualCAD 150000 96 + , locations = [ ottawa ] 97 + , highlights = 98 + [ "Developer relations" 99 + , "Content creation" 100 + , "Technical writing" 101 + , "Video production" 102 + , "Generative AI consulting" 103 + ] 104 + } 105 + , Job::{ 84 106 , company = flyio 85 107 , title = "Senior Technophilosopher" 86 108 , startDate = "2024-01-07"
+98
lume/src/notes/2024/go-pointer-constant.mdx
··· 1 + --- 2 + title: "Getting a pointer to a constant in Go" 3 + desc: "From least to most hacky" 4 + date: 2024-11-25 5 + --- 6 + 7 + In Go, sometimes you need to get a pointer to a constant value. This is normally easy, but only if you have a _value_, not a _constant_. Let's say you or a friend are dealing with the AWS S3 API and you need to pass a value to one of the parameters: 8 + 9 + ```go 10 + _, err = s3c.PutObject(ctx, &s3.PutObjectInput{ 11 + Bucket: "mah-bukkit", 12 + Key: "something", 13 + Body: bytes.NewReader(fileContent), 14 + }) 15 + ``` 16 + 17 + Doing this gets you a compile error, because you need a _pointer_ to the string. 18 + 19 + There's several ways to work around this. I'm going to go over them in order from least to most hacky. 20 + 21 + ## Make those constants into values 22 + 23 + You can make a pointer to a value, but not a constant. Lift the bucket name and key values into variables: 24 + 25 + ```go 26 + bucketName := "mah-bukkit" 27 + key := "something" 28 + 29 + _, err = s3c.PutObject(ctx, &s3.PutObjectInput{ 30 + Bucket: &bucketName, 31 + Key: &key, 32 + Body: bytes.NewReader(fileContent), 33 + }) 34 + ``` 35 + 36 + This works in most cases, but you have to declare variables every time. This can look odd. 37 + 38 + ## The `aws.String` / `aws.Type` functions: 39 + 40 + The [`aws` package](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2) exposes some [helper functions](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/aws#hdr-Value_and_Pointer_Conversion_Utilities) that do this conversion for you. You'll see these in the example code: 41 + 42 + ```go 43 + _, err = s3c.PutObject(ctx, &s3.PutObjectInput{ 44 + Bucket: aws.String("mah-bukkit"), 45 + Key: aws.String("something"), 46 + Body: bytes.NewReader(fileContent), 47 + }) 48 + ``` 49 + 50 + This works because function arguments are treated as values: 51 + 52 + ```go 53 + package aws 54 + 55 + func String(val string) *string { 56 + return &val 57 + } 58 + ``` 59 + 60 + ## Making your own generic pointer to anything function 61 + 62 + Something else you can do is use Go generics to make a "get me the pointer of this" function: 63 + 64 + ```go 65 + func p[T any](val T) (*T) { 66 + return &val 67 + } 68 + ``` 69 + 70 + Then you can use it as normal: 71 + 72 + ```go 73 + _, err = s3c.PutObject(ctx, &s3.PutObjectInput{ 74 + Bucket: p("mah-bukkit"), 75 + Key: p("something"), 76 + Body: bytes.NewReader(fileContent), 77 + }) 78 + ``` 79 + 80 + ## The Kubernetes trick 81 + 82 + Making variables and passing things as arguments to functions aren't the only way to do this, there's also a trick I learned by reading Kubernetes source code. I'll paste an example and then explain how it works: 83 + 84 + ```go 85 + raised := &[]string{"foo"}[0] 86 + ``` 87 + 88 + This works by creating an anonymous string slice with one member `"foo"`, grabs the first element of that slice, and gets the pointer to it. This makes the code look kinda cursed: 89 + 90 + ```go 91 + _, err = s3c.PutObject(ctx, &s3.PutObjectInput{ 92 + Bucket: &[]string{"mah-bukkit"}[0], 93 + Key: &[]string{"something"}[0], 94 + Body: bytes.NewReader(fileContent), 95 + }) 96 + ``` 97 + 98 + However every step in this is perfectly logical.