Sun 19 March 2023
I wrote a library that serializes and deserializes markdown to and from python, but more in the style of pickle and less in the style of a document object model.
Hello markpickle
I got the name from ChatGPT.
Origin Story
I wanted an API to support as many mime types as possible. Some mime types are for the people, such as PDF, Excel/CSV. Some time types are for the machines, like json, bson.
I thought, what about HTML and text? HTML has a problem with XSS risks. Text has a problem of not having much of a standard story for "styled" plaintext. Except for Markdown. Can I use markdown as a mime type for what starts out as a JSON object?
Challenges
The app is two functions, loads and dumps and they take or return an Any type and take or return a string. The Any is a problem, because mypy doesn't know how to deal with arbitrarily complex types. It seems to get confused with Unions of Unions of Unions. It gets confused with generics, e.g. lists that can work with any contents.
Impedance Mismatches
Markdown has some analogies:
- header groupings + paragraphs make dicts, or even nested dicts
- Lists or lists of lists
- tables are dicts, but you can only put scalars in the values. This makes python objects of a certain level of nesting unrepresentable.
- strings and non-string types can be represented, but you can only infer a number should be integer. This blocks round tripping.
Some things are impossible
- empty dictionaries, empty lists exist in python but have no representation in markdown. An empty list is just zero-length whitespace where the list is not. This blocks round tripping.
Python has no use for a lot of markdown formatting, such as bold, or code block or quote. Those things would just be strings and they'd continue to hold markdown in the string.
Read and Comment »
Sun 26 February 2023
I'm going to talk about how I'm managing my health and how it is going
Overall Goal
The overall goal is to maximize your healthspan. More and more people are making it to or close to their maximum
lifespan, of something close to 100. At the same time, more people are getting lifestyle diseases that mean they will be
sick a good chunk of that.
What I Eat
I would still be vegan if the health data wasn't panning out in favor of plant based diets. I believe the data
demonstrates that I've lucked out and my ethical preferences match up with my health goals.
I was omnivore until age 16. I read a book that made the case for vegetarianism and adopted it. I ate dairy and egg
until about age 38 or so. Despite the dairy, for most of the time I tried to be "low fat" which is somewhat
contradictory if you eat any cheese at all. For this whole time I had a healthy body weight, 145-150 lbs for a 5'11"
guy.
I am vegan for a bit over a decade. My lipid numbers are great. Blood pressure fine, but could be better.
What I do
I ran in high school, I did a few years or two of no particular exercise. After starting a desk job and getting colossal
back pain, I started doing follow-along exercise on DVD videos. That worked out great. On and off, I did bicycling,
scootering, roller-blading, hiking. I resumed running about a decade ago and have been particularly serious in the last
five.
Mood
I think that we all suffer from anger, depression and anxiety in different ratios. Depending on what ratio you got, you might have a personality, or a diagnosable disorder.
Optimizing
Between eating right (vegan) and exercising (running) I'm doing pretty good. Everything else is a micro-optimization.
I'm also pushing 50. Even if you eat right & exercise you'll still age. I got grey hairs & when the knee parts fail, they really fail. Some joints have the start of arthritis. The eyes have nuisance cataracts.
- Vitamins
- B12. Only bacteria make it, animals don't. Heck even farm animals have to take B12.
- Creatine. For sprinting & strength training
- Magnesium. Because I run and sweat a lot.
- Hibiscus - Weak anti-hypertensive.
- Coffee - makes me type faster
- Sometimes
- Algal Omega Fatty Acids. They are taken up by the brain. Who knows it if helps.
- Other B vitamins.
I used to, but no longer take multivitamins, the data on them was negative.
Sources
My favorite source on this sort of thing is Dr. Gregor. The rest of the sources are lost to memory, because they were
books I checked out at the library.
Read and Comment »
Sun 12 February 2023
I'm training for another half-marathon, learning prompt engineering and trying to switch to fish.
Running
Last December, I ran my 1/2 marathon, got a mild case of extensor tendonitis (self diagnosed) and then the holidays and side projects took over. So I ran between 5 and 7 miles per week most weeks. This week I'm back to 21+ miles per week.
I got a half-marathon coming up fast, in 7 weeks, so I figure I need to ramp up to 6 miles a day. That means the running I do over the next 3 weeks has the most impact, if it takes 4 weeks for training to have an impact. Last time I did a surge of training, I did daily split sessions and strength training most days.
Side Projects
My most successful side project has been cheaper_openai which I created when I heard they might charge $42 a month. The lower price came out and I cancelled my satellite radio and signed up. Which should you use? Assistant (ChatGPT) is for hard questions, coding. Davinci is for experiments where:
- having a machine make many similar request would help, e.g. trying to get a funny joke
- having code compile the response would help, e.g. book writing
- the response is machine-readable, e.g. generating json, yaml, etc
Otherwise, most of the time, Assistant is smarter.
The rabbit-hole of shells
The sh and bash shell are both annoying, brain-damaged programming languages. I tried to get Davinci to generate a whole book on fish and powershell shell programming as well as how to do shell-programming-like tasks using python with mixed results.
Optimal shell workflow (which I haven't achieved myself)
- fish for a daily driver
- python for anything not mostly just calling other commands (i.e. not 90% subprocess code)
- powershell for anything windows specific or where the code for some reason needs to be shell
- bash for esperanto of scripts, but with none of esperanto's charm or personality
Short story, I think I'm going to try to make fish my default shell.
Read and Comment »
Sat 21 January 2023
Github and ChatGPT experiments, learning about mono and polyrepos
Migrating my docker images to github.
I find Github's pricing guidance bemusing, but it looks like I can host more public images on Github than I can on Dockerhub (many more than 1 vs 1). The limits are on bandwidth per month (1GB) with no obvious guidance on how that is calculated.
Anyhow, my Stackoverflow novelty build tool and my text editor novelty are both available prebuilt.
The most challenging part was learning about Github secrets.
- I used a recommended workflow file that logs into Dockerhub and Gitlab
- I had to realize GITLAB_TOKEN is automatically available and I don't have to create such a secret.
- I had to create an environment
- Set that environment to "all branches"
- I had to edit the workflow file to explicitly name a
environment: NAME_OF_MY_ENVIRONMENT
Next I guess I will experiment with pex/shiv and other ways to package a
Monorepo and polyrepo build strategies
I just started looking at this stuff. They both appear to be alternate ways to deal with dependency hell. If you read up on the sort of solutions for monorepos, you get ideas for doing the same thing with polyrepos, e.g. builds that trigger builds in other repos, making changes to many repos at the same time as a sort of "transaction".
So far, I've found tools like gita which run the same git command against many local repos. The build server part depends on your host, but API for github, gitlab, etc, would simulate the build-script-of-build-scripts. Anyhow, cool stuff.
Playing Toca Boca on ChatGPT
My 6-year-old daughter and I have been playing Toca Boca with ChatGPT. It is difficult. You prompt needs to:
- Get it to stop saying, "Oh, I'm just a model, I can't do anything"
- Get it to stop saying, "Oh, I'm just a model, I have no wants"
If you tell it to write at a 6-year-old's level that helps.
Another challenge is that Assistant can't cope with arbitrarily messed up English. Humans can just sound out a 1st grader's text and get it, but Assistant just can't cope. It isn't sounding out word, it can't hear.
Read and Comment »