Threads for travisbhartwell

  1. 1

    If I have the energy, I am going to be working on a couple of my personal projects.

    • I really need to add Zsh completion support to my MyCmd script framework. It’s a hierarchical script launcher, for example, mycmd financial import chase-visa will run the script in ~/mycmd/financial/import/chase-visa. I need to write completion so that it can dynamically expand to the available scripts, and then their arguments, at runtime. I’ve found a blog entry that had an example that gives me enough to start figuring this out.

    • I’m also working on a tool for data entry for the data around my home peritoneal dialysis treatments. I’ve started writing a version in Python, partly because the Textual library is so compelling for making TUIs. However, I really would love to move away from using Python, so I have started playing with an implementation in Rust. I’ve got the basic data structures defined and now need to hook up Serde for persisting the data. Developing the UI looks to be a bit more complicated in Rust, so we’ll see.

    1. 2

      I have end-stage renal disease, and have been doing home peritoneal dialysis for the last nine years. With that, I have daily records of my vitals and the results of my treatment that I have been keeping on paper. It was high time that I had it in electronic form, so I have started the dialysis-data project to write something for data entry and analysis.

      Last week I got the basic data types defined and basic persistence to JSON for storing the data complete. This weekend, I plan on cleaning up this code a bit and starting to make something loosely along the lines of Clean Architecture for this project. Then I’m going to start diving into figuring out interactions using the Textual Python library.

      I haven’t had much time recently to do development and so my skills are somewhat lacking at the moment.

      1. 2

        Anyone else see the headline and think it was referring to ClarisWorks, the successor to AppleWorks and predecessor of iWork?

        1. 5

          Back in the glory days of Apple Developer Tech Support in the late 80s, they published a whole Technote on “The Dogcow”, which had become their mascot. That technote established the dogcow’s name as Clarus. This was also the early years of Claris the software spin-off of Apple, so I’m sure the name was a joking reference to that.

        1. 2

          I recently did something similar when processing the output of an AWS CloudWatch logs insights query using the AWS CLI and aws logs get-query-results, where the shape of the data is roughly:

          {
            "results": [
              [
                {
                  "field": "field1",
                  "value": 1
                },
                {
                  "field": "field1",
                  "value": "foo"
                }
              ]
            ]
          }
          
          aws logs get-query-results --region=us-east-1 --query-id $query_id > query-results.json
          jq -r \
                          '[ .results[] |
                            map(with_entries(if .key == "field" then .key = "key" else . end)) |
                            from_entries ] |
                           (map(keys) | add | unique) as $cols |
                            map(. as $row | $cols | map($row[.])) as $rows | $cols, $rows[] |
                            @csv'  query-results.json > query-results.csv
          
          1. 3

            I found out that an issue that was blocking me in iTerm (mailing list post, iTerm Issue #9889) has been fixed in a recent beta. This will allow me to finish writing some integrations with Alfred and the shell that I have been writing to handle various tmux sessions either locally or on remote hosts. Will be nice to get that all working.

            1. 3

              Working more my little shell commands library inspired by the blog post sd: my script directory by ianthehenry. So far it’s enabled me to write re-usable scripts instead of a lot of the throw away code I was writing in the past.

              The big thing I need to figure out is how to best generate completions for zsh for commands implemented with my library. I’ve only done very basic implementation of zsh completion functions and so I need to figure out how to write something to provide the completions on-demand.

              1. 1

                Been inspired by the blog post sd: my script directory and want to implement something similar for my own use, particularly at work.

                Considering writing the dispatch program in a compiled language instead of a shell script, for performance reasons. This is particularly as I’m considering adding a --completion parameter that will be called by the zsh completion functions to get dynamic information based on the script command directory contents and I want this to be as near instant as possible.

                Trying to figure out which language to use that would be the easiest for me, as I don’t typically use language implementations with native compilation.

                1. 16

                  This is more of a console based program than a CLI, but VisiData is an essential part of my workflow when dealing with structural data like CSVs. So much more convenient than using a spreadsheet like Excel and very effecient.

                  1. 4

                    I’ve never seen VisiData before - it’s amazing! Thank you!

                    1. 3

                      Paul’s doing a Strange Loop workshop and I’m so sad I have to miss it due to conflicting obligations.

                    1. 2

                      I’d be interested in learning how the compiler is bootstrapped. This says it is self-hosted, and so I’m curious to see how it is accomplished. I see there is a bootstrap directory with some C files with content that appears machine generated.

                      1. 2

                        The compiler has a C backend. Those C files are most likely output from the compiler compiling itself to the C backend to bootstrap on machines without a cowgol compiler.

                        1. 1

                          Ah, that makes sense! I missed the C backend part when I was skimming the docs. Very cool.

                      1. 1

                        The universal hooks thing is sometime I’ve been thinking about myself lately. I appreciate the power that advice in Emacs Lisp and would love that same power in my shell.

                        I haven’t started implementing anything yet, because each time I come up with a design, the shortcomings are very quickly obvious.

                        1. 2

                          Kind of reminds me of Ken Thompson’s classic ACM Turing Award Lecture, Reflections on Trusting Trust. He talked about getting a Trojan Horse into the system via the C compiler.

                          1. 2

                            It’s been a while since I last read that; it is indeed a classic.

                            Reminded me of a story a family member shared, they worked in a secure office, the sort of place with faraday cages and true air gapped networks. A breach had been detected in one of the offices and “everything with a microchip needs to now go in the shredder” they were informed as someone turned up with a big machine with teeth on wheels.

                            An entire room of equipment was destroyed that day to be replaced the same day due to it having lost all trust all because one machine on that network being potentially compromised.

                          1. 3

                            I’ve really been enjoying Dave’s content on this channel. Even though I’ve not always been a fan of Microsoft as a company or Windows as a product, I’ve enjoyed learning about his experiences working on MS DOS and Windows during his time at Microsoft.

                            His series on Windows Task Manager (starting here) – which he was the original author of – was interesting. He even got permission from Microsoft to show some of the code. Very cool to see how he designed it to run under various constraints.

                            1. 2

                              I’m working on small tools in Rust to help me with my personal finance data entry. I’m really making progress in understanding Rust.

                              1. 1

                                I was able to make enough progress this weekend on my little CSV to Ledger importer in Rust that I am now using it to get caught up with my data entry for my Ledger to prepare for filing my taxes.

                                I’m really liking Rust more and more. And I even correctly used lifetime annotations and understood why I was using it as well!

                                I still have to better grok how to handle errors and the like, but I like Rust and the ecosystem in it, especially some of the really high quality crates like eyre, csv, regex, serde, and structopt.

                                Not bad for a weekend of work for someone still relatively new to Rust: https://github.com/travisbhartwell/financial-tools/compare/f1cb58e93729a4f7eb4c81fbc068ca29974adca8..c8caf40d05b6d30cb82c861d568d0a531f896661

                              1. 3

                                I recently lost (due to not having backups nor putting the scripts into source control) some Python scripts that I used to help with data entry and maintaining data for my files I use with Ledger CLI. I’ve learned my lesson, have set up a git repo and am rewriting what I lost in Rust. I know there exist other tools to do what I want, but this is more of an exercise for learning Rust than necessarily merely replacing the lost functionality.

                                Also, I need to upgrade my work Mac Book Pro to Big Sur, so I’m working on getting everything backed up and cleaned up and doing the upgrade there.

                                1. 4

                                  Though this is a TUI-app and not a CLI app that many of the others in this thread are, I have to mention Visidata. It is so handy for viewing and manipulating csv files.

                                  1. 2

                                    In the Game State section, the author has this sentence:

                                    Normally I avoid dataclasses on account of their being mutable, but here that’s what we need.

                                    I wonder if frozen=True in the dataclass definition is not sufficient for their needs here. Both the data class documentation [1] and the similar documentation [2] for the popular attrs library’s parameter of the same name indicate that true immutability is not possible in Python.

                                    If you want true immutability in your code, Python is not a language to guarantee that.


                                    [1] https://docs.python.org/3/library/dataclasses.html#frozen-instances

                                    [2] https://www.attrs.org/en/stable/examples.html#immutability

                                    1. 1

                                      It’s less that I want “true” immutability and more that I prefer the sorts of code patterns that you’d associate with immutability. In practice I use NamedTuples instead of dataclasses, but as you point out they’re not truly immutable. Usually they’re close enough though.

                                    1. 2

                                      VisiData is easily one of my top favorite tools I’ve discovered in the past couple of years. It’s my go-to whenever I deal with CSV or relatedly formatted data. Huge ups to Saul and co for an awesome project.

                                      1. 1

                                        At work, I’m starting work on a documentation project for a client, documenting how to use the particular software stack we’ve been working on for a while for them.

                                        Also at work, I need to do some reworking of the build process of Riak Exploer to make our internal automated snapshot builds a bit more useful.

                                        On the personal side, I’ve been wanting to start a new project. Though I’m sure there are already tools to do some of what I want, this is more of an exercise that just happens to be motivated by a real-world problem. I have an old back up drive that most consists of copies of data from home directories of old machines, going back well over a decade. I’m wanting to collate and move all of the useful bits to a newer drive (before this old drive dies). So I want to write a tool to index my drive. By file name. Find duplicates by content hashes, etc.

                                        I’m thinking I want to do something with Python 3, I’ve not written a Python 3 project. I’m thinking Python 3 + MyPy + Hypothesis + Attrs + Click. I have an empty directory for the code. But I haven’t even gotten as far as writing a requirements.txt. Want to do that.

                                        Are there any good examples of Python 3 first or only projects out there (applications, not libraries) that I can look at? I haven’t written much high quality Python code for a while now, so I’m out of the loop.

                                        1. 2

                                          xonsh is a shell writen in python3: http://xon.sh/

                                        1. 5

                                          I started work on an Emacs dmenu replacement for dwm a few weeks ago and I hope to release something this week. It’s now morphed into something that doesn’t use Emacs (it uses zsh instead). Funny how these things go.

                                          As for the “why did I get into this” category, I’m going to write a new backend for Gnus to manage my paper database. I realized that they’re just “articles” and I want to mark them as read as well as make notes on them. I use Gnus and it seems like a decent fit for my needs (either that or it’s my hammer of late).

                                          1. 3

                                            I actually wrote a dmenu replacement myself, originally about 7 years ago. I wanted a GTK window for it instead of the minimalist dmenu design. It was also an excuse to write an application in Haskell: gtkmenu

                                            I’d like to add fuzzy searching to it and clean up the code a bit, but it’s something that I use every day without fuss.

                                            1. 1

                                              Cool! I’ll check that out. Thanks for the pointer.

                                          1. 8

                                            Or just use magit in Emacs, which automatically shows you a diff in one buffer and you edit your commit message in another.

                                            1. 4

                                              Yeah, magit is my favorite tool in a long time - the support for viewing staged diff chunks and operating on them individually - including discarding them if they’re just e.g. debug prints - is pretty great.

                                              It’s also being improved regularly, for example I like the new command for starting a new branch and cleaning up the current branch (probably master) after you’ve already committed some things - magit-branch-spinoff, that’s not in the online docs yet: github.com/magit/magit/blob/master/Documentation/magit.org – search for spinoff

                                              1. 1

                                                Thanks for sharing about magit-branch-spinoff. That looks useful! I haven’t been tracking what the new features in magit are, perhaps I should!