~mrlee/www.leemeichin.com

e57692209aa36bdd1181184280927d46be67d7e7 — Lee Meichin 16 days ago 96c1740
Convert strong
M posts/can-you-crack-the-code.org => posts/can-you-crack-the-code.org +13 -13
@@ 13,23 13,23 @@ I presume you've seen this kind of puzzle before: there is a lock that requires 
◊hr{}

◊div[#:style "text-align: center"]{
  ◊strong{CAN YOU CRACK THE CODE?}
  *CAN YOU CRACK THE CODE?*

  🔐 _ _ _ _

  ◊b{9} ◊b{2} ◊b{8} ◊b{5}  
  *9* *2* *8* *5*  
  ◊p{One number is correct, but in the wrong place.}

  ◊b{1} ◊b{9} ◊b{3} ◊b{7}  
  *1* *9* *3* *7*  
  ◊p{Two numbers are correct, but in the wrong place.}

  ◊b{5} ◊b{2} ◊b{0} ◊b{1}  
  *5* *2* *0* *1*  
  ◊p{One number is correct, and is in the right place.}

  ◊b{6} ◊b{5} ◊b{0} ◊b{7}
  *6* *5* *0* *7*
  ◊p{None of the numbers are correct, in any place.}

  ◊b{8} ◊b{5} ◊b{0} ◊b{4}  
  *8* *5* *0* *4*  
  ◊p{Two numbers are correct, but in the wrong place.}
}



@@ 43,7 43,7 @@ If you're unaware of Prolog, it's a /logical progamming/ language that, in its m
  Programming in Prolog is significantly different from conventional procedural programming and requires a readjustment in the way one things about programming. Logical relationships are asserted, and Prolog is used to determine whether or not certain statements are true, and if true, what variable bindings make them true. This leads to a very declarative style of programming.◊^[1]
}

Mr Merritt is, to put it professionally, ◊strong{god damn right}. Here's a valid Prolog program:
Mr Merritt is, to put it professionally, *god damn right*. Here's a valid Prolog program:

◊codeblock['prolog]{
  % https://swish.swi-prolog.org/p/KfdGtcJr.swinb


@@ 103,23 103,23 @@ Here's the puzzle again, for reference:
◊hr{}

◊div[#:style "text-align: center"]{
  ◊strong{CAN YOU CRACK THE CODE?}
  *CAN YOU CRACK THE CODE?*

  🔐 _ _ _ _

  ◊b{9} ◊b{2} ◊b{8} ◊b{5}  
  *9* *2* *8* *5*  
  ◊p{One number is correct, but in the wrong place.}

  ◊b{1} ◊b{9} ◊b{3} ◊b{7}  
  *1* *9* *3* *7*  
  ◊p{Two numbers are correct, but in the wrong place.}

  ◊b{5} ◊b{2} ◊b{0} ◊b{1}  
  *5* *2* *0* *1*  
  ◊p{One number is correct, and is in the right place.}

  ◊b{6} ◊b{5} ◊b{0} ◊b{7}
  *6* *5* *0* *7*
  ◊p{None of the numbers are correct, in any place.}

  ◊b{8} ◊b{5} ◊b{0} ◊b{4}  
  *8* *5* *0* *4*  
  ◊p{Two numbers are correct, but in the wrong place.}
}


M posts/gettin-ziggy-with-it-pi-zero.org => posts/gettin-ziggy-with-it-pi-zero.org +1 -1
@@ 10,7 10,7 @@ Alright, you can read the article first and shoot me later for a title like that

Zig, for the unaware, is a fancy language that looks to be to C what Rust is to C++. Honestly, I recommend you read the summary on the main page◊^[1] to find out more yourself, as the best I can do is to just parrot what has already been written. However, you can see it as a valid /alternative/ to C and Zig itself has claimed that it wants to be a better version of C than C itself. An ambitious challenge, for sure. To that end, Zig itself ships its own C compiler.

I've been interested in giving Zig a spin for quite a while, and once my Raspberry Pi Zero W◊^[2] and OLED display◊^[3] arrived in the post, I decided that this would be my best opportunity to try it out. I'm not really going to cover the process of wiring up the hardware, suffice to say that once you've got your Pi Zero you'll need to be able to SSH into it, and that you'll need a [solderless] GPIO header◊^[4] to plug the OLED display into. I recommend the Zero ◊b{W} because the W means 'WiFi', which means that if you connect it to your network you can SSH in without faffing around with USB cables and what not. It's not a requirement, though.
I've been interested in giving Zig a spin for quite a while, and once my Raspberry Pi Zero W◊^[2] and OLED display◊^[3] arrived in the post, I decided that this would be my best opportunity to try it out. I'm not really going to cover the process of wiring up the hardware, suffice to say that once you've got your Pi Zero you'll need to be able to SSH into it, and that you'll need a [solderless] GPIO header◊^[4] to plug the OLED display into. I recommend the Zero *W* because the W means 'WiFi', which means that if you connect it to your network you can SSH in without faffing around with USB cables and what not. It's not a requirement, though.

With that out of the way, let's see if we can write something in Zig to power this little display. It's going to be a simple program that simply fills the entire screen by turning the pixels from black (off) to white (on). As an extra challenge, we will do this without pulling in dependencies like WiringPi◊^[5], or relying on existing drivers, as lovely as they are.


M posts/human-after-all.org => posts/human-after-all.org +1 -1
@@ 28,7 28,7 @@ Realistically, everyone will have some combination of all those negative traits 

Whew, better bring this back to the topic I had in mind before I go off on another tangent.

◊strong{Compassion}.
*Compassion*.

I like compassion. Actually no, I /love/ it. It's an amazing word that can mean many things to many people, but I like to think it's what gives this world the soul it has; it's certainly responsible for a lot of good. The Compassionate Mind◊^[3] dedicates over 500 pages and thousands upon thousands of words to this, and this is what the blurb has to say about it:


M posts/i-am-here.org => posts/i-am-here.org +1 -1
@@ 28,7 28,7 @@ That's one hell of a tortured metaphor, but I think we all have our own individu

To bring this back to the start, I would not change a thing as my place in this moment is entirely a function of all that shit, and all that wonder, I've been through over the years, going right back to my birth and my childhood as an adopted, abused kid. All of the pain, both given and received, and the pleasure, have served a purpose and I appreciate those experiences as I would not think or feel the way I currently do were it not for them. I would not value empathy and compassion and inclusivity so massively. And rather than focussing so heavily on just how shitty some of those moments have been, the amazing memories that have come from my struggle through it all are equally incalculable.

This isn't to say all my problems are solved, or I'm finished with my process. That's ◊strong{pure BS} as this stuff lasts an entire lifetime as you learn, grow and adapt to new situations. But the track record I have must be pretty good if I'm /here/, right?
This isn't to say all my problems are solved, or I'm finished with my process. That's *pure BS* as this stuff lasts an entire lifetime as you learn, grow and adapt to new situations. But the track record I have must be pretty good if I'm /here/, right?

◊footnotes{
  ◊^[1]{◊<>["https://en.wikipedia.org/wiki/Breathwork"]}

M posts/using-ruby-c-in-ruby.org => posts/using-ruby-c-in-ruby.org +1 -1
@@ 83,7 83,7 @@ For every step in this post up to creating a ◊code{String} object, we've been 

The string object is different, however, as on the C side of things Ruby is taking a pointer to a C string (a ◊code{const char *}), allocating memory, and giving back a pointer to the new object. Eventually the GC will run and free up the memory at the pointer's address, and the string will no longer exist. You'll probably find something else at that address instead, or just garbage.

Disabling the GC in this instance is a ◊strong{shitty hack} because it's a direct admission that the code is /not memory safe/. Hopefully you didn't need me to tell you that, though, and the quality of the code in this post was self-evident.
Disabling the GC in this instance is a *shitty hack* because it's a direct admission that the code is /not memory safe/. Hopefully you didn't need me to tell you that, though, and the quality of the code in this post was self-evident.

How would you fix it? Well, now we've found out that we ◊code{can} write Ruby with itself we'll explore that next time. And there'll be benchmarks, too.