I recently got a NUC 11 kit, got a Samsung SSD
and quite a bit of RAM, wanted to follow the official guide to
installing NixOS 21.11 from a USB flash drive, but I ran into a few snags, especially when doing the partitioning of the drive.
When working with third-party services, one is more likely than not to end up parsing
a JSON document. For well-behaved APIs, documentation and examples are available, so the job
usually becomes some minor variation of:
Reach for the "canonical" JSON parsing library in your language
Grab some example JSON and do some ad-hoc parsing of the bits you're interested in,
Maybe write a class/type/module/namespace to immortalize adapting said JSON data to your domain, hopefully with accompanying tests.
Think everything is okay, until some live data comes in with missing keys (or extra keys!) inconsistent types (nulls where they promised they wouldn't show up, invalid date
formats, etc.)
Go back to step 2 with the newfound edge cases, adapt.
Sometimes it's a quick process: couple of caveats you missed in the documentation, sometimes
it's painstaking; the ability to close the loop in a fast, but robust, manner becomes invaluable: you don't want to spend days, and a lot of boilerplate, only to discover that some deep details didn't really work out. I believe a good type system and a good parser help a lot, but the last mile is all about the "getting to the bits of data relevant to your domain." Optics are my tool of choice for that.
As part of my astrological forays, I built a little library that can traverse an interval of time and find significant events (changes in moon phase, a planet going retrograde/direct, ingresses into zodiac signs,
transits, eclipses.) The data produced is necessarily verbose: you get back a sequence
of events, and each type of event carries information about itself; in some cases,
said information can be composed of further complex data (e.g. a Transit can tell you
all the phases of application/separation it goes through in the interval, and each phase has a beginning and end.) To have to go through a sequence like this and
pattern match and deconstruct in different ways depending on your use case seemed like a lot of annoying boilerplate that I, as a library author, could do better to help with than to just give you the types to pattern match, some good names, and a firm handshake.
And this is when I realized what's so great about a popular, albeit intimidating, concept in the Haskell ecosystem: optics: the ability to build greatly upon "cheap" abstractions.
In the past year of not updating this blog, even though I said I would, I've been quite busy
shaving yaks: in addition to the apocalypse, house work, and my day job, my wife and I have been
working on a little Jungian-oriented astrology app with an accompanying Haskell backend.
This has meant a surprising amount of new terrain to traverse, and I'll try to jot down some
of the highlights here: I've gone from
the depths of C memory tomfoolery, to the heights of actually reading some books and papers on category
theory, passing through the vast fields of Haskell type level programming. I'll try to cover a bit more breadth than depth in a couple of "stories" from the Haskell trenches.
I haven't posted anything to this blog in almost 10 years . In fact, for a while there I've considered it defunct, because I didn't have anything to say. Or rather, I lacked the emotional and intellectual wherewithal to write about technology. But I hope to get back into the groove of things, and I'd also like to look back at these ten years, for a lot has happened. Let's take a whirlwind tour.
In the weekends I like to learn lisp (my favorite lisp is scheme), and, whilst I do it in a chaotic fashion, I end up actually learning. Today I'm reading about continuations, a theme that is mentioned over and over in schemeland and which I hadn't the guts to try and understand. Until I found this chapter in the book "Teach yourself scheme in fixnum days". As eye-opening as it is, what I found most surprising is that ruby also has continuation! So I'll sum up what I learned about continuations using ruby for the examples. All the examples and content are either paraphrased or taken directly from the above book.
This might come off as yet another developer ranting against java, so let me state this before even stating my goal today: I think java is a neat language which shows off some good ideas that have clearly influenced the programming community for the past years.
But, as highly as I think of java as a kinda good designed product and harbinger of very nice things, like the java virtual machine (cradle of fine languages like scala and clojure)and the widespread use of just-in-time compilation, I consider that teaching it as a first programming language is harmful, because in teaching it you have two choices: either delve into thorough and sometimes hard explanations as to why things have to be done the way they're done or resort to magical explanations: "write it like that because I say so". And both have equally pejorative consequences: the former leaves little time to teach the fundamentals of programming, like control flow, functions, recursion, environments/computational objects, logic and testing; and the latter sets a rather weak foundation which dooms the future of future engineers/computer scientists.
I started working in a project, and it was using fossil as it's scm. I cloned it and began doing my stuff, at first it felt weird, as I am a git user, but eventually I got the knack of it and it feels nice and clean, definitely easier than git. However, because I'm not part of the official project (i.e. I'm working on a fork, if you wanna hear git-speak), I didn't have write privileges on the server, so I decided to host my own copy.
I had to apply an exam this week for a web development for beginners course I'm teaching. We're using ruby for the server side for a couple of reasons: heroku is an excellent option for one's first deployments and I wanted to get a better grip on Ruby on rails 3 and html5 for my own improvement (and I've found that there's no better way to learn stuff the good way than teaching them).
No decent developer can survive without some sort of source control management. The one I know more of is git and I'm a huge fan of github. We're actually using github organizations to manage the class projects (the github staff is really great, they've let me use private repositories for the student groups at no extra charge).
Today, I was writing a tutorial for a class I'm teaching on how to use git+github for group projects. We had a lab earlier so I already knew which things needed more support (like diagrams or screen-captures) and which needed real-life code results.
I'm gonna give a little talk about java to some people in a couple of days. Yes, java, the new cobol, the language I secretly know, lest I'm banished from the cool kids club. But it has cool stuff. The java virtual machine, the bytecode compiling, the support for unicode and the blessed jruby. I mean, we can run ruby on appengine thanks to java! So get that frown off your face and let me tell you 'bout something cool.
Mongrel2, the language agnostic web-server. That sounds rad. So, naturally, I had to install it. I am, at the time of writing, barely reading the chapter three of the book but managed to go through the installation thanks to the very detailed guide provided there.
But I ran into some (easily fixable) issues, which I'll share for posterity and the sanity of others.
I migrated my personal site to jekyll today, as I said before; for my blog, I wanted something simple, codinghorror, simple and yet a little simpler than that: I don't like the clutter of sidebars and footers, but there had to be a way for people to navigate amongst my entries (I also don't assume that people have the best internet connection ever to load all my posts in one page).
Yesterday I had no money to go out and the weather sucked. So I decided to pick up one of my side projects and hack for a while.
For that project I need to fundamental components, a way of extracting keywords in a text and a wrapper for the public rss feeds of delicious.com. So I created webtagger and deliruby (this morning I thought to rename it to "delirious", which is cooler, but, well, nevermind) and released them as opensource gems for whomever wants to to hack them and use them. I think it's cool to be able to release something easy to use for others (using gem install instead of downloading the source, extracting it, installing it and all that fuzz).