Dependencies

I did a lot of work on the serum-dex-ui module last night. I’ve been writing a lot of Python code to modify the NFT json feed and parse it into the various forms that I need for the serum-history and dex UI modules. Went even further and used it to generate the React code I needed to build the drop down menus that are made in antd. Anyways, it’s been paying off. I’ll need to figure out some sort of way to automate updating two or three git repos based on changes in the feed, but I’ll get to that later. Right now, I just want to get this thing live so people can access it.

Right now our test instance is running the site off of yarn, the repo has a static build system. It’s got a Github Pages build, but I started standing up an AWS Amplify setup. I’ve never used it before, but it was actually pretty damn easy to configure it to checkout the Github repo and build. The problem is our market data is actually being injected into the app through one of the Serum dependencies in node-modules. This doesn’t work in a CI/CD environment, so I’ve got to figure out how to remove that dependency and refactor the app to use our fork.

One other note about my work last night: we had a couple misnamed symbols, which were used as primary key prefixes in the Redis database. Each symbol had multiple keys, all of which needed to be updated at the same time that the symbols were updated in source code in the two repos. I managed to find a blog post, Renaming Multiple Keys in Redis, that provided a few lines of pipelined code that could do the trick. We only had about seven or eight incorrect tickers, but since this needed to be done quickly I coded it out in Python, using a dictionary that mapped out the erroneous symbols to the correct one.

for old_symbol, new_symbol in changes.items(): 
  print("""
redis-cli --scan --pattern {old_symbol}-*  | \\
awk '/^/ {{new_key=$1;gsub(/{old_symbol}/,"{new_symbol}", new_key); printf "*3\\r\\n$6\\r\\nrename\\r\\n$" length($1) "\\r\\n" $1 "\\r\\n$" length(new_key) "\\r\\n"  new_key "\\r\\n";}}'  | \\
redis-cli --pipe""".format(old_symbol=old_symbol, new_symbol=new_symbol))

Voila. I have been meaning to take a longer look at awk as I think it may be useful for the Solana multisig metaprogramming code that I want to work on. I’d been writing it in bash, but now I’m second guessing whether a Python module might be a better choice. It weird that I’ve been learning Rust and React, but keep going back to Python. I had a spectacular moment last night when I realized that I needed to add an additional attribute in from a loop to be used later within another loop. I was cursing myself because I thought it would be a pain in the ass, but I had a flash off insight that made me feel like a shadowy super coder. I simply turned one variable into a tuple and called it later in the code. It can’t possibly be this easy, I thought as I hit the run button. But it did, on the first try, and I felt like a goddamn genius.

The rest of my work today, not so much.

On a personal note, I spent another two hours staining the deck. Got the floorboards done, although there are a couple light spots that will need a bit more spray. I managed to finish the inside of the railings. So all that’s left now is to do the outside of the railings and touch up the tops where there are new boards. It’s hard work doing it by myself in these short spurts. And trying to do it with plastic or cardboard behind where I’m spraying is a huge pain as well, but I have to do it to keep the sprayer from getting all over the house or the hot tub. I’ve had limited success there, I tell you. I don’t know if I’ll be able to get it done in one more session, or two, but I’ll be so damn happy to wrap this up.

And today was also my quarterly board meeting with Elder. She loves Chinese buffets, but the ones we have here in town are so crappy. We pigged out, but the food wasn’t that great. Then I took her to a couple of discount stores to buy a toy and some makeup. This was the third time we had one of these daddy-daughter days. It wasn’t the greatest, but I had to remember to take time with her in the midst of the business that we’re going through.

We watched What If…? when we got back and then did our own thing. I cut the grass for what must be the third time in less than two weeks, and now the kids are in bed.

Tomorrow I’ve got my weekly SAIADao update for the membership, and will be working more on getting the dex up and running. I want it live this week.

Leave a Reply

Your email address will not be published.