Search
×
press ESC to close

Day 17 of 100

progress

  • reviewed adding excel conversion to cli
  • shelved this after reviewing implementation requirements
  • this is one of those cases where PowerShell makes much more sense for adhoc work as converts pscustomobject (similar to struct) via pipeline automatically to excel sheet.
tech development 100-days-of-code 100DaysOfCode golang 

Day 16 of 100

progress

  • refactored AWS SDK call to export a named file using flags.
  • Iterated through regions so cli call aggregated all results from all regions into single JSON.
  • Working with v1 makes me want v2 so much more. The level of pointers required is ridiculous. At one point I had something like &*ec2 due to the SDK requirements. Having to write a filter with: Filters: { Name: aws.String("foo")} is so clunky. I believe in v2 this is greatly simplified, and the code is much cleaner.
tech development 100-days-of-code 100DaysOfCode golang 

Day 15 of 100

progress

  • figured out scope issues with pointer and struct
  • Used omitempty in struct
  • exported final report in json format after searching for matching image id from ec2 instance image id
  • Find it interesting how much more wordy the go search method was, but appreciate it in a way as the “syntactic” sugar that’s missing also is the reason there is more complication at times in languages like PowerShell/C#.
tech development 100-days-of-code 100DaysOfCode golang 

Day 14 of 100

progress

  • Migrated my new aws lambda logger from zap to zerolog. Zap gave me some problems initially so zerolog is my favorite structured logger right now, much simpler.
  • Constructed go-task runner file for launching go test and go build/run.
  • Structured logging required a little bit of refactor but worked.

Here’s an example of providing back a logged string (don’t log secrets normally, but I’m in testing phase) with structure.

	log.Debug().
		Str("decodedBinarySecret", decodedBinarySecret).
		Str("secretString", secretString).
		Msg("Depending on whether the secret is a string or binary, one of these fields will be populated.")

Based on my improved understanding of conversions vs type assertions, the need to convert using a “cast” (Go calls these conversions, and yes it makes a copy in memory for this):

log.Info().Str("requestDump", string(requestDump)).Msg("request information")

Type assertions are done when working with an interface. I’m still working on my understanding of interfaces as they are their own beast in Go. Unlike most other languages, a Go type implements an interface when all the required methods are matched. This provides a great deal of the flexibility in Go interfaces.

The scoping of the interfaces is important, and while I listened to a lecture on this, I didn’t yet work through the interface design principles to ensure the best resusability/narrowness of scope concepts. I think that’s going to take more “getting my hands dirty” for it to click.

tech development 100-days-of-code 100DaysOfCode golang 

I couldn’t get past this for a while when I accidentally stumbled across a fix. I believe the fix was merged, however this problem still existed in 0.13.4 so I stuck with it.

When investigating the cause, I found this PR which intended this to be the installer behaviour for the implicit global cache, in order to match 0.12. Any providers found in the global cache directory are only installed from the cache, and the registry is not queried. Note that this behaviour can be overridden using provider_installation configuration. That is, you can specify configuration like this ~/.terraform.d/providercache.tfrc

GitHub Issue Comment

I used the code snippet here: micro ~/.terraform.d/providercache.tfrc

Wasn’t sure if it was interpreted with shell, so I didn’t use the relative path ~/.terraform.d/plugins, though that might work as well.

provider_installation {
  filesystem_mirror {
    path = "/Users/sheldonhull/.terraform.d/plugins"
  }
  direct {
    exclude = []
  }
}

After this terraform init worked.

tech development microblog terraform troubleshooting 

My morning. Explaining set and intersect theory basics to my 10 year old with Minecraft gamer tags. Trying to justify the need to know this, the best I could come up with was his future need to build a shark attack report accurately.

Kids are the best. Tech is fun. What job would have me spin up with docker-compose up -d my MSSQL container, write a quick SQL example with INTERSECT, UNION and all to demonstrate this magic.

Followed it up with a half-hearted lie that my day is comprised of cmatrix ๐Ÿ˜‚ which he didn’t believe for more than a couple seconds.

tech development microblog dadlife 

I’ve been enjoying Codespaces local development workflow with Docker containers.

I’m using macOS and on Docker experimental release. Here are some ideas to get started on improving the development experience.

  • Clone the repository in the virtual volume (supported by the extension) to eliminate the binding between host and container. This would entail working exclusively inside the container.
  • Increased Docker allowed ram to 8GB from the default of 2GB.

Any other ideas? Add a comment (powered by GitHub issues, so it’s just a GitHub issue in the backend)

tech development microblog docker codespaces visual-studio-code 

I took a quick step back when too many parentheses started showing up. If you question the complexity of your quick snippet, you are probably right that there is a much simpler way to do things.

I wanted to get a trimmed message of the results of git status -s. As I worked on this snippet, I realized it was becoming way overcomplicated. ๐Ÿ˜†

$(((git status -s) -join ',') -split '')[0..20] -join ''

I knew my experimentation was going down the wrong road, so I took a quick step back to see what someone else did. Sure enough, Stack Overflow provided me a snippet.

$(((git status -s) -join ','))[0..20] -join ''     # returns the string '12345'

Moral of the story… there’s always someone smarter on Stack Overflow. ๐Ÿ˜†

tech development microblog 

Day 12 of 100

progress

  • Worked on Algolia index project to do atomic updates on search index on my blog.
  • Worked with json, structs, ranges, and more.
  • Saw success with the first value in my output now correctly parsing out the title from the front matter.
  • Implemented zerolog.
  • Used front library to parse yaml front matter into map.
  • Accessed map to get title into json.

Hoping that eventually I can build out a Go app for sharing that’s the equivalent of “atomic alogia” allowing diff updates. I haven’t found anything like that for hugo so far.

tech development 100-days-of-code 100DaysOfCode golang 

Beat Deadcells with 3 cells active. Uninstalled. There is no way I’d find any pleasure in life trying to do more. This game is an endless pit of “git gud”.

Now to go do something productive ๐Ÿ˜„

gaming ramblings 

A quick fix to improve your debugging of remote commands in AWS is to install cw.

With a quick install, you can run a command like: cw tail -f --profile=qa --region=eu-west-1 ssm/custom-automation-docs/my-custom-doc. This will give you a real-time stream of what’s running.

You can also use the AWS Visual Studio Code extension, but I prefer having a terminal open streaming this as I don’t have to go in and refresh any further tools to see what’s happening. I tend to always start with a single instance/resource for debugging so this is a great way to remove the barrier to visibility a bit more.

tech development microblog cool-tools aws golang 

Checkout delta for a much-improved git diff experience. I typically use VSCode or a GUI based editor because I find the diff view pretty messy by default.

This new diff view is a perfect example of a simple CLI tool that improves a development workflow by just fixing something I didn’t know could easily be fixed. ๐Ÿ˜€

delta diff viewer

tech development microblog git cool-tools 

Day 10 of 100

progress

  • Experimented with CLI tool using go-prompt
  • Customized initial options
  • OS independent call to get user home directory.
  • Iterated through a directory listing
  • Used path join to initialize path for directory search.
  • One challenge in working with structs being returned was figuring out how to print the values of the struct. Initially, I only had pointers to the values coming back. This made sense, though, as I watched a tutorial this weekend on slices, and better understand that a slice is actually a small data structure being described by: pointer to the location in memory, length, and the capacity of the slice. Without this tutorial, I think seeing the pointer addresses coming through would have been pretty confusing.
  • In reading StackOverflow, I realized it’s a “slice of interfaces”.
  • Worked with apex logger and moved some of the log output to debug level logging.
  • Final result

source

tech development 100-days-of-code 100DaysOfCode golang 

Day 8 of 100

progress

  • Worked through Algorithms in Go: Determine if a number is in a list
  • Passed the tests without needing to find the solution, so that’s a win.
  • Had to remember to grab the second value from the range operator like for _, i := range items instead of using foreach($i in $items) like PowerShell would do. It’s more similar to using hashtables with GetEnumerator().
  • Used codespaces with Docker and also experimented with WSL2 and Visual Studio Code mounting the directory from inside WSL2.
tech development 100-days-of-code 100DaysOfCode golang 

Migrated a forked copy of a module over to a new module with similar schema. There were some additional properties that were removed. In rerunning the plan I was expecting to see some issues with resources being broken down and rebuilt. Instead, Terraform elegantly handled the module change.

I imagine this has to do with the resource name mapping being the same, but regardless it’s another great example of how agile Terraform can be.

tech development microblog terraform