Oh, metaclass!

Looking at a friend’s python code which have tens of lines of metaclass. I thought I know __metaclass__ which is how Django implemented its database model. But then I rethink maybe I don’t know it very well.

Google showed me What are metaclasses in Python?

Oh, it’s a great answer! It’s using the “refactoring to patterns” style, telling all the magic behind it with a reasoning process. It tells you how to fish!

To me the Python3 metaclass is new, but makes a lot of sense. I’m glad I found it.

Silly memory modules issue on my iMac

I have an iMac 27″ (2017), which shipped with 8GB memory (2x DDR 4 2400 8GB). I upgraded it to 32 GB (4x DDR4 2400 8GB modules, Patriot Viper) when I got the Mac, and used it for 2 years without any problems.

2 years ago, I saw a deal of Crucial 32GB (2x DDR4 2666 16GB modules). I thought that I can install them into this iMac and then repurpose the Patriot Viper memory modules for my Intel NUC mini-PC. I remembered removing the 4 modules form the iMac is pretty hard, there’s no way to grab them firmly. But other than that I remember the replacement is success and the iMac is stable for a while (greater than 6 months).

And then for almost a year the iMac starts to develop stability issues. It will restart abruptly (showing different kind of kernal panic), showing four languages what not. I was thinking maybe the fans are fault or maybe the mainboard, graphic cards developed age issue. I also suspect that the Mac OS have too much garbage in the libraries folder.

And then couple of months ago the Montery upgrade breaks the APFS partition, leaves a huge “black whole” of disk space. There was 512GB SSD but visible capacity is about 200GB. It turns out that’s some weird APFS hidden volume bug during OS upgrade, which may related to iPhoto’s photo caches. That’s OK, I can do time machine and partition from scratch to address that issue. But that addressed the disk issue, but the system is still restarting every other day.

One day, I thought I should try to replace the memory modules, because that might be in fault with all different kind of kernal panics. Maybe the older iMac is not suppose to run the memory at 2666Mhz, that might be a issue.

Then I pulled the 4x 2400 modules, pushed them to the iMac, restart, no boot. Then I pull 2x of them out, leave 1 & 3 modules in. And then the iMac boot flawlessly (note, you need to wait about 20 seconds before the iMac can boot when you press the power button). Then I run couple of stress tests (stressng), it’s pretty stable. I run the system for couple of days and it stays stable! So maybe my hypnosis is right and I should use 2400 modules.

Then I tried to push the 32GB 2666 modules in, mixed with 16GB of 2400 modules. That won’t boot. Try 2 & 4 modules with the 16GB modules, won’t boot. Try 4 modules of 8GB modules again, won’t boot. And then to make sure I captured the ghost I installed the 32GB 2666 modules at 1 & 3 again, oops, it booted. And then for couple of days, it’s stable.

OK, I think the problem is resolved. But I have no idea why! I seems a year of stability issue might be some electric conduction issue? Anyway, it’s hard to “reproduce” this kind of issue sometimes. So the IT solution of “kick it and restart” might works.

Fixed a SSL cert issue on my blog

I remembered I saw my site’s SSL was not working. So I visit it today (how lazy I am). I see it’s complaining my cert belongs to blog.diamondtin.com instead of www.diamondtin.com. I forgot why I choose www.diamondtin.com over diamondtin.com, but I’m sure I have long abandon the domain blog.diamondtin.com.

SSH to my server I found my certbot settings is very messy. That auto detected config changed my nginx config and somehow prioritize the blog.diamondtin.com as the primary domain name. So I manually deleted the domain from certbot and nginx. Restart, and it seems OK now. If you still experience problem, please ping me on twitter @diamondtin.

Experience the 2021 Macbook Pro

My family went to Westfield having lunch together. While we wait our dishes, I took a quick detour to Apple store to experience the new Macbook Pro. I had watched couple of reports and video reviews, but I’d like to experience them in person. I only have about 5 mins to experience them.

The 16 inches feels really heavy! The previous 16 inches is also heavy, I just don’t lift them up very often. My work computer is a 2019 16 inches (last gen before the 2021 Macbook Pro), which also feels cold and heavy. I will just type MBP instead of Macbook Pro. The new MBP feels heavier and thicker, and it’s not just a feeling, the did. But that’s totally OK. The new rounded corner body is really good, I really don’t know why you need to create the sharp corner on previous unibody MBP. I mean the square corner looks professional and cool, but they feels pretty bad in hand or on lap. I’m glad MBP’s shape is back to “a good feel” and friendly again.

And then I feel the keyboard, they feels as good as the previous “upgraded” keyboard. The worst keyboard is those on Macbook “lovely”, the shallowest version. And the infamous butterfly keyboard is bad. Current version is totally OK. I have a wrong impression that the arrow key’s layout is changed to something like a normal keyboard (which have same size for every key). But unfortunately those arrow keys still have 1/2 size for up/down arrow. I really hate that design! So that disappointment is still there. But maybe that’s an industry’s problem now, I think all laptop’s arrows are just using 3 keycaps’ spaces instead of 4.

And then I checked the screen. The apple store is very bright, and the 1600 nits brightness screen does stand out. But the light condition in apple store has glamour, last time I experienced the 24 inches M1 iMac its screen are also very impressive. I tried a HDR 4k video on YouTube, which looks just OK. I don’t have HDR monitors at home, so I can’t compare. Also the HDR content eco-system on YouTube is hard to trust. So maybe I just choose a SDR video which mark itself as HDR, I should check the video info (but I forgot). And then I used the “Photos.app” checked the photos, they looks gorgeous. Interesting thing is that all the photos are taken either on iPhone 13 or iPhone 13 Pro Max. A lot of those photos are taken in California, mostly mountains of Santa Monica Coast. Maybe instead of those gorgeous screen maybe we should use the phones in our hand to capture some good photos. I feel not all the light are natural in those photos, at least some of them have reflector boards used?

And then I used the 14 inches MBP. This one feels like the one I may get. (NO, I will not buy it this generation) It feels much lighter than the 16 inches, the screen is definitely in the same league of the 16 inches screen. Keyboard size and layout are the same. I didn’t test the speakers in both 14 and 16 MBP, the reviews saying they are great. If the only difference is the size and weight, then I will definitely go with the lighter one. That’s one of the benefit of owing the M1 chip Macs. I need to cut through my materialism desire, I should use what ever I have to entertain myself. And for work, I should just use what company gives.

Then I try to test the 3D capability. I don’t know what’s the best thing to try. So I just open the ocean horn 2 on the MBP. But this game used a blur rendering powered by Unreal. I expect Unreal’s rendering quality should be better. But this grain and blur 3D rendering is not impressive at all, I don’t know how to change resolution too. So I didn’t get any sense how the 3D rendering capability of the MBPs.

Next time.

Chocolate Orange

I don’t know why, but this piece of memory surface up again when I read my favorite book Zen and Motorcycle Maintenance. Let me put it on my blog then.

It happens on west side of ThoughtWorks Beijing office. @cread visited our office for Mingle. He would help us create a software installation package for Mingle. The scene happens about the end of the day, his first day visiting Beijing Office. Chris have strong British accent, which gave me some hesitation sometimes because my English listening was not great. He says “Almost forgot, I get chocolate orange!”. Chocolate and Orange sounds like a weird combination based on my limited experience, so I double check what I hear is right “Chocolate Orange?!”. Chris replied “Yes, chocolate orange.”. My head was bursting weird idea, not sure if that’s orange flavored chocolate or some toy? Chris brings out a white cupboard box with some cutout on it which looks between fancy chocolate and toy, so that appearance doesn’t assure what I see. I was imagining how a bursting fruity orange flavor will blend with chocolate’s distinguished flavor, that may not work well? So I asked Chris why it’s a good idea to blend orange flavor with chocolate? There’s an odd expression on Chris’s face, and he said “Oh, no, it’s just orange shaped chocolate”. Oh, it’s not orange flavored. Then I feel even more odd, I thought a big round ball (bigger than a bulb) of chocolate will be very hard to bite or break. So I asked “why they make big orange shaped chocolate ball?”. This time Chris didn’t answer my question directly, he just pull the orange shaped ball with orange color alumnium foil wrap out of the box. And then he hold it, lift it up and then heavily drop the chocolate ball on the desk. Bong! The aluminum foil wrap popped, and then the chocolate ball opened on the desk like a water lily, or I can say it opened like you cut a whole apple with an apple slicer/cutter. I wowed, and then all my questions are answered.

Winding road

Yesterday, we just went back from a vacation. I was tired physically, but very satisfied mentally. I lost some photography gears during the adventure, but that doesn’t matter. What I want to say is those tiny lost can’t compare what myself and my family got from the long-overdue vacation. I feel that I’m living a life again, I’m in control of my emotion.

Today, I woke up with a motion-picture in front of my closed eyes. I see winding road moving ahead, like what I see from a drone’s perspective. The winding road has not much scenery around, there’re not much details. The winding road goes left and then right and then left, it curves naturally and I feel like flying. I get that feeling when I swim in the shallow and turquoise sea near Hapuna beach, I can see the sea floor and I’m flying above it. I love a winding road without motion sick, the road is my new hope.

I’m grateful, feeling surrounded by love.

A Serious Man (Almost can’t make it)

I’m very serious recently, like a serious man. Since the Pandemic starts, I rarely feels less serious. Seriously, I lost friends, sleep and humorous, like a tree burning inside.

My family, my reason for life, plan a Hawaii trip with another family this summer. I know everyone is flying to this island to get rid of their tedious prison time at home, and I think that popular idea is not too silly. My brilliant wife booked a very very nice vocation home at the big island, and it’s about 4 time the size of our current home. And Hawaii is just a couple of fold better than San Jose where famous for their sands industry.

That vacation feels like a hole of light when I’m trapped in a dungeon. I’m counting every last bit of my fingers and toes. That’s the hope that I will not murder by my new boss in my deadly enterprise company, if I miss the flight I will definitely found dead. American has a drinking problem, and I lost my sense of beer tasting, totally eclipsed by the guilty of drinking. I can’t fake. I have no talent of beer tasting, I’m just using that as an excuse. There’s no cure for being a dull and tasteless soul. Not even Pixar’s soul, which is brilliant BTW. Before I gave up myself to “Church of Jesus Christ of Saints of the Last Days”, no offensive, but you may know that’s the joy of being a fundamentalism (so you won’t be a hacker). Oh, I mean it’s hard to be a good dad, being optimistic, being a OK husband. I feel that is a wormhole to reborn. Maybe I can be “not serious” about everything, like a desperate meat ball.

When I march through this long and dark tunnel, I can see the light is at end of the tunnel. It’s only weeks away. It’s my nirvana, like “Negative Creep”.

And then, a day, then weeks, I get stuffy nose and other allergies symptoms. It’s OK, it happens every year. It’s the pollen, a good year for vegetarian, bad for my nose. Every year my months of allergies turns to Sinusitis around May, this year no exception. Oh, some exceptions, I also get a very sore throat. I mean like something burning inside, I shared the link above, that’s what I felt. I virtually visit my doctor, she is so nice, she told me that I should be under antibiotic. Oh, lovely, I love writing scripts with a powerful language. Penicillin is as lovely as PHP, which is the best language in our world. Penicillin is definitely better than beers! When I can eat Penicillin I will not even dream about beer. I was so happy, I start to worry. I worry that my nose and throat may get worse.

Oh, and it did. I lost my voice the next day, even with my favorite Penicillin. I didn’t get my bonus fever though. Lost voice is a good thing, I don’t need to show up in meeting. I just kissed my pillow for 2 work days, and a weekend. On a Monday, my voice becomes funny. My throat is burning. But my nose feels better, the Penicillin works. And a week later my voice sounds less funny, but throat is still dry, burning, like the unlucky California tree, still burning inside. Oh, it’s OK, it’s still two weeks until our vacation, I still have time to win the battle with feeling stressed of ruin my vocation being down.

Time flies to 72 hours before the trip day. We need to do our COVID test together. I’m sure my dry throat is not because of COVID, I got my Pfizer shots and are fully cooked.

But the night before the COVID test, my younger daughter got fever. I can’t believe that happened, I’m shocked it’s not a nightmare, it’s real. But we still need to do our test. We drive a hour and visit a city 1 hour away from our home, that’s another indicator that everyone is flying to Hawaii. I’m a serious man, doing a COVID test for a hot baby is a good idea, we can tell if she got COVID!

The next day, we got a good news that everyone is negative in our family. I mean we really feels negative, because our vacation is very close to vaporized. We will not fly when anyone in our family has COIVD, we will also not fly with a hot baby! Oh, I forgot the good news that we are COVID negative. One thing is off the list, but our little flower is still fever “not free” on that morning! It’s 48 hours until the flight. I’m a serious man, we almost can’t make it. Indeed!

But our little is fever free on that 47 hours mark. And then she stays fever free until 24 hours mark hit. So we have a thin hope to fly honestly (fever and symptom free, and COVID negative). But in the meanwhile I don’t feel sick, but my throat still feels funny, I still get dry mouth at night, I still feels like shit that we almost can’t make it. I start to plan for the worst, so I won’t die from heart attack. We start to pack our luggage, like there is still hope, like the summer Olympic this year. I start to worry that theft will visit our home. I found that I forgot my password combination of my safe, a physical safe weight for a ton (a metric ton not US ton, use as a metaphor). Then I search my home, from 1Password to every piece of paper I may use, I can’t find the combination. But I’m looking for that combination? I don’t need my passport, I don’t need money there (and there’s no money in it), I don’t need to use the prime lens in that safe, I don’t need to leak more secret of my life. And then I found the combination, I tested and been positive that I can open and close the door of safe. And then I continue pack my luggage. We sent our guinea pigs to our most thrusted friends’ home, they have a pool so everyone is happy to take care of other’s pets. We even get BBQ treat from my friend, we even tested our Snorkeling equipment from him. He even have snorkeling equipment we can borrow so we can return our equipment bought from Amazon. Sorry to waste some natural resources, I feel guilty because I love what Greta is doing. Oh, you can tell I’m a serious man, I’m talking with my “Rabbi”, and I feels like approaching a black hole. That’s just a metaphor, like what Christ Nolan used in his interstellar. Oh, where is my train of thought. I’m packing my luggage. I packed too much, like moving home. I want to pack a lot of medicines, so that we won’t sick in the trip. At this stage, me, the little flower may be sick at any time. We may be super tired, we may miss the flight. We may catch COVID on the flight because our immune system is weak. Lost our ticket for life is a step away.

I can’t sleep at night. My watch told me I didn’t sleep well. I still need to work, and the work feels heavy like black hole. This is mental disease, I’m not a capable man to raise two kids and keep my wife afloat.

I’m beer free for 3 weeks minus a day. I’m pretty sober but feels worse than those days I drink beers. But you know you can’t trade sin with god, you can’t please gods/goddess. Oh, I forgot to mention. I got neck pain, like lose a wrestling game. That was 3 days before the trip, the day after we did our COVID test. My neck and back just sore like lemon. I can’t tell the difference of sour and sore, I’m a bad language user, I don’t like PHP. I wore my winter cloth, because I see snow at peak of Hawaii big island. I worry I may get more cold and develop more symptom of serious man. I have a metaphysic feeling that warmth helps my neck. But you know that feeling is not much difference of getting helps from god. And I don’t even know how black hole feels. But it turns out the warmth doesn’t help, my neck and back still sore like stoned (I don’t know why stoned doesn’t mean it feels like stone, but have a sinful meaning. I don’t mean that “stoned” literally). So I used a pain reliever called ibuprofen, and it worked. Sorry, I’m not reducing fever, I just want to get rid of the back pain. It doesn’t work that well, my work still feels like sucking my soul out of my skull. So I used a pain relieve cream from Walmart, and it worked! There’s a volcano eruption on my back, near my neck. The ingredient of menthol burns my skin, but rather than that other ingredients do their job. The warmth do work, I mean that feeling like Salonpas patches, they smells like root beer, but they do relieve the pain.

So there’s a chance that I can reborn before the flight, my ticket to life. And only time can tell.

I’m writing this in Hawaii. I’m not detained by police. Our flight didn’t dive into sea water. Black hole doesn’t burp with our earth. So we actually made it! Flora is fever free and have a very high spirit. My wife didn’t divorce me. But Hannah did get her fever from yesterday, but then fever free for a whole day. Lyft scheduled pick-up worked. We get a XL car, and it caries our over-sized luggage just fine. No traffic, no traffic accident, no highway cops. We didn’t catch COVID, finger crossed. The Hawaii travel’s official website do work, and our PDF is not eaten by my Mac. We don’t have food poison. I do get some deep sleep before the trip, at least better than some other horrible day. I didn’t lose any electronics on the airplane. I didn’t forget batteries of drone, cameras. My back pain is still with me, but fades a bit. I get a blister on my foot, but it’s not broken. I still make mistakes, but they didn’t take my ticket to reborn.

Oh, I’m a serious man. I will go to interview, find some work which doesn’t eat planet earth. I still suck at leet code, but that will not take my ticket to reborn. I have some cash to stay afloat even my boss hate me. I love my daughters, my wife, my parents and the beautiful world. Hawaii is nice. It’s not as weird/cool as Australia, but very nice. It’s the same feeling to hear “Aloha” after you did your apple fitness+’s mindful cool down. The ramen place we went right after landing was a disaster, but it won’t take my ticket to reborn. There’s a small beach near the nice rental house where kids can practice snorkeling before they go to real snorkeling.

I’m doing my meditation, and my neck is sour like sore. I did drink an Ola light hazy IPA yesterday, and that taste worse than my home-brew hazy IPA I yielded last year. Which make me feel like not the worst beer taster in the world, at least I can brew something not horrible. Oh, I’m not saying Ola beer is horrible. It’s using the wrong malt bill and wrong yeast, used not enough dry-hopping and added to much hops to their wort. I’m the most hateful person in our group, because I critics like hell. But today, I start to joke like I used to be. Because I know I’m a serious man, and you can tell the end is as black as it is in the movie. You can only blow that gravity away by a laugh, like the serious Sci-Fi TV serious “Dr Who” (Sorry I only see maybe 3 episodes of them, and they are old, scary but fun. Newer episodes are boring, see I like critic like hell). And then I cleaned all the dishes, cleaned kids’ wounds from today, washed myself. Then I sit down, alcohol free, writing a poem of myself down. I will post it on my blog, I’m not a private person, I’m the opposite.

I lied a lot, like I used to be. But there’s some truth in this blog post, like I used to be. I hope that I actually get a reborn, been lighter body, been funnier, been serious only with none-PHP-language and maybe English and Chinese. I don’t want to lose my sleep, and the 3 hours time difference helps, it’s still before 10PM when I finish typing the words before this sentence. Why I’m pouring this much of negative words here? Because I’m really a serious man? I never own a motorcycle but I love to learn how to do maintenance of them. I love the craft of living, like I love making coffee and tasting beer.

Hope tomorrow I will fly away from the black hole, lands in Island Hawaii. Seriously joking like that’s the real quality of life.

Simple design is zen

Dan North (a.k.a. the BDD guy) tweets:

SOLID is well known Object-Oriented Design principles, Uncle Bob introduced this acronym in his book. If someone ask you about design principles in a technical interview, this probably is the most sound answer. But I totally get Dan’s point, those acronym is cool but hard to apply in practice. I mean everyone who is good at code know what is good design, and those principles does apply well. But in most of time, this is like a review of stock market. It make sense, but you can’t use the review to predict the market. I feel they are confirmation bias.

Please take a look on Dan’s deck “Why Every Element of SOLID is Wrong”, it’s humorous. His point is “Write Simple Code”, which I dig. This is a way to say don’t trust prediction of stock market, use your common sense. It’s not because any simple code is good code, it is just saying that you should “Chop Wood Carry Water”.

The goal of Zen, his master taught him, was to “archive a void … noiseless, colorless, heatless void” – to get to that state of emptiness, whether it was on the mound or in the batter’s box or at practice.

Before that, Zhuang Zhou, the Chinese philosopher, said, “Tao is in the emptiness. Emptiness is the fast of the mind.”

Quote from the book Stillness Is the Key

I feel the “Write Simple Code” tag line is in the spirit of zen. Always want to apply best practice, design principles feels like ego. We have an impression those pattern matching process make perfect code. But the order is wrong. We can refactor code to use patterns, but pay upfront cost to use pattern may be a waste. If we can put down our ego, we can just go back to our emptiness and write simple code. Make It Work Make It Right Make It Fast. Go back to basic, Chop Wood, Carry Water, Chop Wood, Chary Water.

How to backup your videos from iCloud?

It feels silly that I need to write a blog about this. When I google how to do this correctly, I found zero articles to solve the problem I’m facing. Some of them are outdated, some of them are talking about something else.

My problem with iCloud videos is capacity. I’m currently using the 200GB iCloud plan, and that runs out of storage. I can upgrade my plan to 1TB, maybe eventually I will do. But I feel this is not sustainable if I don’t delete some content and just let it grow. If I can live for years, then those photos/videos will outgrow what money can buy. So the solution is easy, I need to offload some big files in my iCloud. In my case, 75%+ space is used by photos and videos. I need to archive some of them which doesn’t bring much sentimental value to me and save them on some back volumes.

The first try I did is use the https://www.icloud.com/photos/. That’s easy, I just view “Albums -> Media Types -> Videos”, since they are normally huge in size. And then I need to download them and delete them. A couple of files in, I found a problem. The video I download has “creation time” and “last modified time” at the current moment. That’s useless for video archive if I can’t tell when and where they’ve been taken. Photo files have exif but videos don’t. I’m not familiar with the metadata standard for videos, but somehow iCloud can tell it in its interface. I already selected the “unmodified originals” when I download those file, so I guess that’s some limitation of how browser handle file downloads. But this is a dead-end, I didn’t find any way to archive downloading that over iCloud on the web.

Then I go back to my Photos.app on Mac. There’s a feature of Export, which has a sub-option of “Export Unmodified Original for x videos”. On the next dialog, you can choose “Export IPTC as XMP”, “Filename: Use File Name”, “Subfolder Format: Moment Name”. This option is very helpful. I finally get my videos exported with the right “creation date” and “last updated date”, they are even been organized in a nice name folder including location and date. Say “Golden Gate Park, April 18, 2015” is very descriptive for a video 🙂

But then I found another issue. I can’t see all the videos that I can see from iCloud’s “Albums -> Media Types -> Videos” in my local Photos.app. Then after some research, I found the issue is because I migrated and then moved my iPhoto library to the Photos library. And after that somehow this Photos library is no longer my System Photo Library. You can click “Option” while you open the Photos.app, and then you can tell which one you are using. Once you choose the right Photos library, go to “Preference” and click the “Use as System Library”. It tries to scare me by saying any photos which are not uploaded to iCloud may be lost. But anyway I need to go ahead. Then your Photos.app will start to sync up with iCloud. But that is very slow. I waited for about an hour but there’s still nothing showing up from my iCloud. All the photos and videos are downloaded from my iPhones, which means they already have a copy in iCloud. So the behavior of re-upload them into iCloud is useless.

Then I figure out the right solution. I can click “Option” while opening the Photos.app, this time I choose to create a new Photos library. Then I can go to preference and set it “Use as System Library”. This time the iCloud photos under “Albums -> Media Types -> Videos” will show up with short hesitation (download metadata from iCloud). After that, I can use the “Export Unmodified Original for x videos”. On the next dialog, you can choose “Export IPTC as XMP”, “Filename: Use File Name”, “Subfolder Format: Moment Name” option to export those videos as you do with local Photos Library. And then you can delete them, which also removes them from the iCloud library. Eventually, that storage will be reclaimed. Problem solved. To sum it up:

  • Create a new Photos library
  • Set the new Photos library as “Use as System Library” in Photos.app’s preference; Go to iCloud tab and choose to sync up with iCloud Photos, use “Optimize Mac Storage” to save some SSD storage Use as System Library iCloud Photos Sync
  • Let it sync up a while, so your videos will show up in “Albums -> Media Types -> Videos” Albums
  • Choose the video you want to archive, you can choose multiple by using “Ctrl + Click”
  • File -> Export -> Export Unmodified Original for x videos Export videos
  • On the next dialog, choose “Export IPTC as XMP”, “Filename: Use File Name”, “Subfolder Format: Moment Name” Export Options
  • Check the progress bar (a white/grey circle on the top left bar of the Photos.app window), make sure the export is done
  • Right-click and choose to delete videos