Thoughts

Byoby Aggressive Resize Error on Iterm2

Bradley Noyes published on
2 min, 363 words

I love tmux and screen and byobu -- which uses screen or tmux as backends -- for terminal work. I suggested these utilities to my co-workers. These are great utilities which allow you ssh into a machine and preserve your ssh sessions even after you log out, or loose your internet connection.

I use iterm2 on my laptop for ssh (in fact, it's the app I spend most of my time using). Iterm2 has integration for tmux so you can open new Iterm2 tabs through a remote tmux session as if there local iterm2 tabs.

But there is a pesky issue in Iterm2 regarding tmux support, the dreaded, aggressive-resize error.

Read More

Serde Deserialize This or That into u64

Bradley Noyes published on
4 min, 771 words

Recently I ran into a bug in my code; hey, it happens. The bug was that I had a struct which could serialize into json, but could not deserialize from its own json. The struct holds a value for a mac address, which is 48-bit integer (that i store in a u64), but it is serialized using the network interface name. For example on my mac, i have a network interface named en1 with the mac address of 20:c9:d0:b0:a4:71:

Read More

A Short Serde Deserialize example

A Short Serde Deserialize example

Bradley Noyes published on
3 min, 509 words

In my previous post, I described taking a simple enum and creating a custom type in diesel. This post will take that same enum and implement deserialize.

I often get tripped up by the mechanics of deserializing so this simple enum makes for a good example. Again, this is to benefit anyone looking for more examples of Serde's Deserialize as well as for myself, so I can remember next time I need to do this.

Read More

A small custom Bool Type in Diesel

Bradley Noyes published on
5 min, 989 words

I've been working with diesel and serde. I use diesel for my postgres datastore, and serde for serializing/deserializing data to the web. Recently I came across a situation where I needed to define my type in diesel as well as implement deserialize in serde. The example below is a fairly simple so it makes for a good example to share so others can learn (and so I can remember how all this works next time I need it).

Read More

Shebang for C .... Almost

Shebang for C .... Almost

Bradley Noyes published on
3 min, 527 words

Shebang for C ... Almost🔗

Sometimes I need to write a small C program that lives as a single C file. It's too much overhead to write a separate Makefile to compile one C file, so how do you easily remember how to compile it? If there are no dependencies (i.e. library or include paths) then its pretty straightforward to run gcc or clang by hand. But what if there are a handful of dependent libraries that need to be linked to the program or include lines? Crafting that compile line can a frustrating exercise in searching your shell history. A possible solution is to embed the compile line embedded at the top of the C file, like so:

    /*
     * to compile: gcc hello.c -o hello -ldl -m -L/usr/local/lib -L/other/long path/my_lib/ -lmy_lib ...
     */
    ...
         
    int main() { ... }

But that's amature hour, here's how you really should do it ...

Read More