naesnaes

Posts

I intend this to index some of my knowledge-keeping and sharing.

Heap Escape Analysis in Go

Warning

This page is extremely rough and will contain incorrect code and lack of explanation.

I want to figure out if my go program is making any allocations to the heap.

go test -run none -bench . -benchtime 10s -benchmem

Output:

goos: darwin
goarch: arm64
pkg: src.naesna.es/aoc/go/2024
cpu: Apple M1 Pro
BenchmarkDay1Part1-10              56686             62211 ns/op           83192 B/op         26 allocs/op
PASS
ok      src.naesna.es/aoc/go/2024       4.405s

You can also get a memory profile

-memprofile mem.out

Then use go tool pprof to check allocation space.

Advent of Code 2024, Day 5 Part 2

I wanted to write about this day, since I thought of a nice way to solve this, which is the first time I’ve actually used this algorithm outside of class.

I’ll give a bit of a teaser: Topological Sort.

Problem

Go check out the real website, https://adventofcode.com/2024/day/5 for a full picture, but I’ll try to give as concise of a summary as possible.

Your Input

  1. You are given a set of rules, like a|b, meaning number a must come before number b
  2. You are given a few arrays of numbers, and
    1. For Part 1, you must sum the middle number of all arrays that conform to the above set of rules.
    2. For Part 2, you must sort the invalid arrays and find the sum of their middle numbers.

Solution

Context You are only given the first problem until you solve the second one.

What should I name my go mod?

When I do go mod init, what should I init my module as? It seems like convention is to set the go mod name to the page of your repo in GitHub. But why?

Looking at the gomod docs:

The module path must uniquely identify your module. For most modules, the path is a URL where the go command can find the code (or a redirect to the code). For modules that won’t ever be downloaded directly, the module path can be just some name you control that will ensure uniqueness. The prefix example/ is also reserved for use in examples like these.

How to Make the Footer Go to the Bottom

Here’s how I keep my website footer at the bottom. I need these footers to do a few things:

  1. Always be at the bottom of the page
    • When a page is shorter than the height of the screen, then the footer should stick to the bottom of the screen.
    • When the page is longer than the height of the screen, then the footer should be at the bottom of the page. This means that I need to scroll in order to see the footer.

The Approach

Ok so why is this so hard? IDK. Here is an easy approach:

My Obsidian Setup

Obsidian is great. Besides its’ wonderful Knowledge Management features, it is insanely great for just this one thing: Feature-rich WYSIWYG markdown file editing.

For writing things slightly less trivial than a few words in a file (like images, math, or links), it would be really nice to see what it looks like without having another pane open to preview it. You know, real estate is pretty expensive these days!

Here is a guide to my configuration of my obsidian workspace.

Notes on Git

Since git is a massive tool, I want to showcase some things I like using!

I assume the reader has some familiarity with Git in this article. For those new to Git or want a good refresher, I recommend the git book.

Git’s Tools

Aside: Writing Commit Messages

Writing good commit messages is important, even if you work on feature branches! It’s good to get into the habit of writing helpful commit messages, especially if someone later wants to go back and traverse the commit history.

Creating an 88x31 button

I was asked by a friend to create a button for my website. The only spec was that it had to be 88x31 pixels in dimension.

Origin

Something about GeoCitites. It seems like many websites had little 88x31 pixel images that were clickable.

  • Here is an archive of some pixel images: The 83x31 Archive
    • Be warned, this is not very SFW

Purpose

Fun

How

IDK. I ended up making it using paint.js. Then, I exported a few variations to get it animated. Finally, I took the collection of images and assembled it into a gif!

Legacy Pages

Here is a collection of links to pages that are no longer compatible with my current website.

Previous Iterations

Since I keep changing the systems and design of my website, I decided to keep track of it.

V0 - December 2022

This was when I first acquired the domain name, naesna.es.

It started with plain HTML with no CSS at all.

When I started using org-mode and Emacs, I began exporting them to HTML pages within org-mode for more self-documenting types of writing.

Screenshots

The Last Version of my Homepage

Firefox Vertical Tabs

Here is a quick guide to setting up vertical tabs and removing the horizontal tab bar in Firefox..

Vertical Tabs

Install Tree Style Tab

Self Explanatory. I also like having a supplementary plugin for indent lines.

Firefox Extension Links

Remove Horizontal Tab Bar

This requires some more work. First, you'll need to add some CSS to your userChrome.css file, and then you'll have to enable stylesheet customization within Firefox.