:bloogeR is mE

Am I feeling it?

Sept. 1, 2022, 8:27 p.m.

Life is what you make of it.

What if I don't want to make anything of it?

I'm just a paper boat, bobbing in the sea.

The boats I wag past have their anchors cast:

Though they sway about, they stay around.

My anchor's on deck, wrapped over the mast.

 

It's been a long time—

maybe I just don't feel like untangling it—

So the current takes me away.

ncurses is awesome

Jan. 13, 2022, 10:25 p.m.

I've been working on a game that you SSH into a server to play these past few days and building the user interface has been so easy, straight-to-the-point, and most of all very fun with ncurses.

ncurses is a screen handling library that you can use to manipulate terminal interfaces, and its interface and documentation are so damn good.

Literally everything -- all routines, what the prefix on routines mean, what routines return, possible error return values, how most people use it, etc -- is all in the manual so you don't even need to look it up and sift through dozens of articles online with different colors and styles just to catch your first step like so many other libraries.

iOS Hotspot Hacking: Boosting hotspot speeds by over 100 times

July 1, 2021, 7:57 p.m.

The problem

I have no wifi or free hotspots where I'm currently living.

My mobile hotspot, which consumes mobile data, gives me a measly 70kbps even though I am supposed to be getting 3G speeds (around 3mbps I believe).

Youtube takes over a minute to load everything, everything else is abominably slow, and I need a solution to this first-world problem stat!

Brainstorming

Even though my mobile hotspot is 70kbps, the data directly to my phone is much, much quicker (10 mbps).

So, what if we do some finagling and forward all the HTTP requests from my computer to my phone, have my phone very quickly download everything, and regurgitate all the downloaded information back to my computer through USB tethering.

Sounds like all this passing would be very slow, right? I thought so too but boy was I wrong.

Planning

Use USB tethering provided by mobile hotspot (wired tethering is basically hotspot Ethernet, but still capped at 500kbps) to put the phone and computer in the same local network, letting them easily access each other's ports.

Then all I have to do is somehow set up a proxy server on my phone, and let everything on my Windows computer proxy through it.

A major roadblock

Seems simple, but how do you host a proxy server on your phone?

If you're an Android user, you'd probably thinking "just host it on your phone with X gizmo", but I forgot to tell you that I'm doing this on an evil iOS system, notorious for anti-hackability, so we have to find a way around.

All hail Vim

Yes, you heard me right. We're going to use Vim of all things to host the proxy server. I guess Vim really can do anything, huh? Well, we aren't exactly going to be using Vim itself... but a little something-something it's got packaged into it.

There's a very interesting open-source app I found in the iOS App Store a few weeks ago that I've been playing around with called iVim. As you can guess from the name, it's literally just Vim, but on iOS. And if you didn't know, newer versions of Vim have a command called :terminal that lets you open up a whole terminal in Vim.

One feature of this terminal happens to be full Python support... ah, you got it now right? Bullseye! I hosted the proxy server using Python in iVim on my phone! Phew, that's a mouthful, but it works!

Smooth streaming at last

So, after all this work, what are the real, cold-hard results of this little experiment, you ask? My download speeds has gone from 70kbps to roughly 3-5mbps (over 100-fold increase!), and my YouTube videos went from struggling on 480p to playing perfectly smoothly at 1080p.

There was a strange problem with running some applications, where they would directly bypass the system proxy, but I fixed that by funnelling all of the traffic from the problem applications through Proxycap.

Thanks for sticking with me through this journey, and I hope you learned something along the way too!

PLT with "Crafting Interpreters" + An awesome CLI Java debugger on Linux!

June 18, 2021, 1:59 p.m.

Abstract

These past few days, I have fallen into the world of programming language theory (PLT) and along the way found a super useful GDB-like command-line java debugger on Linux!

Preface

After finishing building this blog a few days ago, I wanted to start a new project, but not any ol' project... something that I had never touched before!

And so, after scouring the web for millenia, I found the ultimate peak of computer science -- interpreters!

Well, maybe not the peak, but definitely the peak of what I have done so far.

 

In the summer of '19, my buddy and I organized a super intensive eight-week book-reading of the legendary Structures and Interpretation of Computer Programs.

We slogged through it, but eventually, through hard work, sweat, and the power of popcorn reading, we made it out as enlightened lambda wizards.

However, one great regret I have about that read-through was the last two chapters of the book:

We were worn and weary from the last three chapters that we had just overcome and to read just the first few subsections of the penultimate chapter, we squeezed enough juice out of our brains to fry a motherboard.

At that point, we unanimously agreed that we had already gotten enough out of the book and that the last two chapters were more suitable for when we were more prepared.

After skimming the last two chapters, the book club concluded and we went our separate ways. I'm not sure about the others, but for me, those last two chapters had always stuck with me...

One year -- a hellish college application process, COVID-19, and a blog later, and I'm ready.

I'm sure you've guessed it by now, but those two accursed chapters were all about interpreters and compilers!

And now I'm going to face them head-to-head.

Crafting Interpreters

After all that background, I will confess, I found Bob Nystrom's book purely by coincidence.

I was looking for projects and began researching Donald Knuth (the guy has done so much in computer science and mathematics) and the books he's written, wondering if any of them would be worth reading as a project.

Along the way, I found How to Design Programs and learned an author of the book actually created Racket (a LISP dialect) and DrRacket (an IDE for Racket)!

From there, I somehow found out about some demo programs that came with Racket -- PLT games -- which came with my installation of DrRacket.

I played some of the games and became curious about who wrote the code for these games, as well as about what PLT stood for.

And after I searched for "racket PLT games," an eight-year-old Reddit post popped up.

However, it was not about the PLT games that came with Racket, but instead about a now defunct website called plt-games.com (accessible through archive.org), which hosted competitions for the design and implementation of new programming languages.

I took a look at a few of the submissions for one of the competitions and found the languages people created to be incredibly amusing (see Reduct), and wanted to see how these were created in the first place.

Taking a look back at that Reddit post, guess who I found in the comments... none other than Bob Nyrstrom, giving an interested commenter links to implementations of multiple languages in increasing complexity -- all created by himself of course.

I clicked on one of the links, which brought me to a page showing off the language, which happened to be a subdomain of his website, and found his blog (read it!) from there.

I became enamored with his posts and experiences with writing code and books, and came across a post talking about his love for programming languages which became his inspriation to write a book that he would toil for years making and even end up releasing for FREE!

I started reading the book, Crafting Interpreters, and we're where we're at now.

GJDB

Now on to more technical stuff.

The book specifies an object-oriented C-like programming language called Lox which is implemented twice throughout the book:  A high-level implementation in Java, and a low-level bytecode implementation in C.

I'm working through the Java implementation on a Linux CLI and find my solution to a problem does not work as I expect.

I have used GDB before for C debugging on command line before and really like the minimalist flow the tool gives you.

On the other hand, the moment I executed JDB, the Java debugger, it was clunky, awkward.

I looked online for an alternative and found GJDB on a Berkley professor's personal website, which is an improved modification of JDB last updated in 2014.

Guess what, a Java debugger last updated 2014 is manifolds better and more streamlined than one that's still being updated and packaged with the latest Java SDK today.

However, as of current, the latest GJDB release is 6.4.1 and requires a few tweaks before you can get it installed with JDK 11.0.11.

Download and extract it and make the following changes in the following files:

  1. DIR/configure:98 - Remove the if statement checking JDK version starting on line 98.
  2. DIR/src/ucb/gjdb/Env.java:14 - Remove the com.sun.tools.jdi.* import on line 14.

where DIR is the directory you extracted the files.

Also note that you must have emacs installed (apt-get install emacs25 on Ubuntu).

After that, follow the directions in the README that comes with the source and you should be ready to debug any Java program you want!

 

I'll keep you updated as I work through the book if I find anything interesting!

P.S. All linked books are free!

Making of :bloogeR is mE

June 15, 2021, 2:41 p.m.

Abstract

:bloogeR is mE was inspired by Ben's amazing blog at 16BPP.net and took exactly seven full work-days to complete. This project is created with Django and served with Gunicorn and Nginx.

The process of making the blog was greatly facilitated with the help of many tutorials along the way, which I will link in the related sections below.

Django

Django renders the webpages and manages the database, which contains information about each post. It is fairly similar in structure to the polls app created in the official Django 3.2 tutorial.

Web server

Gunicorn and Nginx are responsible for serving the web pages. Gunicorn is a Web Server Gateway Interface (WSGI) that interfaces between web apps (Django in this case) and web servers (Nginx in this case).

How to set both of these up along with Django can be found in this amazing Digital Ocean tutorial.

Domain certification

I bought this domain off of namecheap.com for about $3 for the first year, but it costs about $20 for every year after... so we will see if I will keep this domain or not.

I certified the web server using Certbot (instructions can be found at the bottom of the tutorial linked above), but I encountered a problem when configuring my domain's DNS:  The domain was seemingly unavailable even though my web server was running perfectly fine.

To fix this problem, make sure you have two "A" records added in your domain's DNS settings:

  • An "A" record with the host as "@" without the quotes
  • and an "A" record with the host as just "www" without the quotes.

Make sure the IP address in both records is the external (WAN) IP address of your web server.

CSS

I had originally used Bootstrap for this project, as it was easy to use and was what I had used for a prior project.

However, I talked with a friend about it and realized BS was very bulky for the client, slowing down load times, and in the end, I didn't actually really like the templates I was trying out.

So ultimately, I bunkered down, scrapped two full days of work, and spent the next two days making my own CSS stylesheet, heavily inspired by the high-contrast format of this graphics research paper.

The final result, in my opinion, is very nice, and I am very pleased with it.