Profile cover photo
Profile photo
Yan-Fa Li
Pragmatic Programmer
Pragmatic Programmer

Yan-Fa's posts

Post has attachment
Budget mechanical keyboard build. Mpow blue switch keyboard for 27usd. 22usd for replacement double injection keycaps from mechanical keyboards. This one goes on the family computer. Very pleased with the with the quality for the price.

Need to replace the function key, but other set didn't come when one.

Dealing with file downloads using a browser as an application developer is still distinctly prehistoric. The primary method, is to create an HTML link element with a href pointing to the server resource you wish to download and an empty download attribute. On the server set the headers on the response for Content-Type and "Content-Disposition: attachment" and then clicking the the link programmatically. This tricks the browser into downloading the file on your behalf and streaming it to the disk. It's incredibly primitive and poorly documented.

These days it's advantageous to use security tokens in headers to enable distributed authentication/authorization. Unfortunately you can't send headers using the link element trick. You choices then are to use XHR requests and trick the browser into sending this to a file via a dummy href pointing at a base64 encoded data url or using a deprecated JS File API. This is a severely limited technique however since it requires you to buffer the file entirely in memory first, which may not be practical with multi-gigabyte files.

If you control the server however your options widen. One possibility is to create a special end point which returns you a one time token that has a fixed expiration, say 5 minutes and permission to download the content you want to share. The process becomes request a download token for the specific content with the authentication header. Take this token and then pass this to a simple URL which doesn't require the auth header. Validate the token and return the requested content. Since this token endpoint doesn't require special headers it can be used with the link element, again tricking the browser into stream the download to disk on your behalf.

The things we have to do to save content to disk.

Post has attachment
Seems like Nintendo just being Nintendo. They seem to prefer to leave money on the table.

Watch an NES Classic Get Unboxed and Torn Down Because You Can't Buy One

Post has attachment
Success! Upgraded the T430 from a 1368x768 panel from AU Optronics to a far superior LG 1600x900 one.

I had a couple of things to do which were quite involved, taking apart the T430 case while not difficult is time consuming and awkward, but I was able to put new heat sink paste on the CPU and clean the fan while I was in there and replace the HD video cable with a HD+ cable I ordered from Ebay.

First boot windows was very confused and didn't initialize the screen which made me very nervous, then I rebooted and cleared the BIOS to defaults and was subsequently able to boot to Windows 10 again. The extra real estate is appreciated and this panel is far brighter and has better color reproduction.

Very happy with this upgrade. The overall cost was about 2 hours, lots of taking apart again because I kept forgetting things and a 50usd panel from laptopscreens. This is the 2nd one I've done so and I've very pleased with the results.


Thought exercise. Now that Apple is no longer in the business of making pro developer laptops, what would a hypothetical device look like?

My wish list:

13-14", magnesium body, 3-4lbs, QHD IPS or OLED screen, island keyboard, glass track pad, m.2 SSD 500gb, 32gb lpddr4, 2-4 core CPU (i5-i7), Aetheros AC WiFi, 2 USB3 ports, 2 USBC, HDMI 2, Mini DP 1.4

High want Ethernet, SDXC Reader, Nvidia 1050ti discrete graphics. USB C charging.

If it ran coreboot instead of the horrific Intel mei stuff that would be amazing, but I'd settle for running Windows 10 and Linux well. I would pay premium apple prices for that.

Post has attachment
Massdrop delivered my PBT double shot lemonade yellow keycap set today. Very happy with how it looks. Gives this keyboard a happy and bright new look. The keycaps make the clears nicer to use and are very thick so have a nice sound when you type. The red keys are OSX command keys I had laying around.

Cleaning out my Arch workstation install was instructive. I'd basically accumulated years worth of desktop cruft and had to remove kde (qt4 and 5), gtk2, gtk3, xfce4, gnome and mate. I used pacman --remove -c liberally and kept cutting until it looked like it was all gone.

Then I reinstalled lightdm, and gtk3 and then mate-gtk3. lightdm refused to start so I had to nuke it's /var/lib files and reinstall them. Once I got a working desktop again I reinstalled just enough stuff to get my desktop back again; firefox, chrome, qt5 for third party dependencies and I was back in business. Weirdly mate does not install a screen saver by default so it won't lock, you have to install that separately.

It's a long over due cleaning. One nasty surprise with systemd is that if the graphical desktop fails to start, the terminals on the console don't start up. Wut? I had to login remotely using ssh. That's just dumb. I suppose I could have used single user mode, but really?

The new LCD panel for my T420 arrived today and it's a vast improvement over the stock panel. The machine is very pleasant to use now in comparison to the old panel. It's still a TN panel but a much more pleasant one.

The upgrade was fairly easy, though I broke some clips for the bezel which will require some double sided tape to fix. The hardest part was removing the tape which held on the connector.

For 45USD including shipping this a worthwhile upgrade if you happen to still own one of these older laptops. It's been a workhorse for me and shows no signs for quitting as yet. I've upgraded the CPU, RAM, Storage (SSD) and finally the LCD on this machine, so it's proven to be a versatile workhorse.

I have a cable on the way for the T430 I recently acquired and I'll be upgrading that one too. Thanks to the dedicated and brave souls who figured out how to do this and which parts are compatible.

I bought a used T430 for use with Windows 10, I need some software that doesn't run under Linux and I don't want to spend money on a Mac. It cost about 200usd. I upgraded it with an old SSD I had laying around - 2nd gen Intel - and dropped another 4GiB of RAM into the chassis bringing me up to 8GiB. It runs very well. I'm very pleased. The T430 is a nicer laptop than the previous T420 I had and it runs W10 perfectly.

The one fly in the ointment is the terrible TN screen. Turns out you can upgrade this too. You need two things, if the laptop came with a 1366x768 screen, you need a HD+ cable - I ordered one from china for about 13usd. Hopefully that one works; secondly you need a 14" LVDS screen with the connector on the left. Turns out there's a compatible one from the Alienware M14X R2. I found one online for about 40USD.

This screen is significantly better than the stock PoS that the T430 ships with. It requires you take apart the screen and if you need the cable, then parts of the keyboard and bezel. I've taken apart by T420 before so I'm not concerned. This chassis is turning out to be a really nice upgrade platform.

I've been puttering around with a low resolution laptop recently (1366x768) and I realized something I hadn't noticed before. All the new material design UIs are terrible to unfriendly at this resolution. For fun I switched back to gmail from inbox to make a comparison and set the gmail UI to compact. The amount of information density is incredible. Inbox is basically all eye candy - modern design with white space and very little information to pixel ratio.

A lot of chromebooks, sport this lower resolution, so its probably quite a pain to use these newer fancy UIs without going full screen. sigh
Wait while more posts are being loaded