Lev's Hacking Notes

Learning React with Mosh

2021-04-12 ][ Tags: learning react javascript

There have been a number of React related things that have come up in my work lately so I figured it was finally time to buckle down and figure out how it actually works.

My biggest frustration with learning anything related to Javascript is how quickly the ecosystem changes and makes tutorials, courses, and books obsolete.

I was looking through some of the recommended resources on learning react from the React website and came across the Mastering React course which I decided to try out.

I am about halfway through the course now and it has been great so far. Mosh does a great job making this topic approachable. I especially like how he walks you through a specific naive implementation and then takes the time to both explain why it is not ideal, along with walking us through how to refactor our code to make it better.

I also really like how he provides tips and tricks in how to be as efficient as possible in working with React and VS Code. I finally figured out how to effectively use multi-line cursors, move code blocks around, use snippets, and the thing that blew my mind the most so far is "zen coding" which takes a lot of pain out of writing complex and repetitive HTML.

The extensions that I've found useful with VSCode are:

  1. Simple React Snippets
  2. Prettier - Code Formatter
  3. Auto Import - ES6, TS, JSX, TSX
  4. Sort Imports

If you're looking an approachable way to dive in and learn React, I would highly recommend this course. I've already purchased the follow-on Redux and NodeJS courses, so I will be a full stack developer before you know it.

This blog is the farthest thing from React. In fact, it has no Javascript at all and I plan to keep it that way indefinitely. However there are a number of side projects that I am working on that would greatly benefit from something like React. My plans after this course are to rewrite the Flashy frontend in React and potentially even dabble with React Native to create mobile applications for Flashy.

Integrating Openring into This Blog

2021-03-25 ][ Tags: python blogging

I just did the jenkiest thing ever.

Openring is a cool little library written by Drew DeVault which allows you to add articles from feeds that you follow to your own blog. It's kind of like a dynamic blog roll.

It was designed for static site generators, but since (for some reason) this blog is not statically generated, I was thinking of the best way to include it and came up with something that is either a horrible RCE waiting to happen, or a clever hack.

I set up a cron job to run openring every eight hours and pop the output to a file. Then in flask, I made a simple utility function to go find and read this file and insert it into a Jinja variable which is then rendered on every post page (look down at the bottom).

This allows readers to check out other interesting content and also has the added benefit of being fresh several times per day.

Bringing Back levlaz/blog

2021-03-25 ][ Tags: python blogging

I was so motivated by Tom's fresh start, that I decided to have a fresh start of my own here. This blog is running on some horrible software that I wrote in 2017. Sadly, I don't have any of the posts that were previously here, but that is probably a good thing.

Yesterday I "unarchived" the repo in GitHub, deleted half of the code that was my poor attempt at allowing people to add comments, updated all of the dependencies, and then shipped this off to my NUC box.

Surprisingly, everything more or less works that way I remember.

Every time I look at this code base I think to myself "why aren't you using a static site generator?". It is a good question and I don't have the best answer. I am married to the idea of taking advantage of the full text search feature of SQLite (which powers the search bar above) and I have not found an equivalently simple solution for any static site generators that don't require loading random JS or using a third party service.

There is probably a healthy middle ground here somewhere and I hope to find it.

Regarding comments, after blogging in obscurity for over a decade nothing that I have written has ever generated enough interest to foster a good discussion on my own site. I am actually OK with that and not trying to reinvent Akismet is a good thing for everyone. The simplest approach to solving comments on this site is to just not have them at all.

If something you read here motivates you and you want to tell me about it, there are many other ways to contact me.

Dropping Pakets and F# Bombs

2021-03-25 ][ Tags: F#

I tried to be clever with the title.

I spent the better part of the evening yesterday trying to get the LaunchDarkly .NET SDK to work in F#. This was a part of my current journey of trying to learn more F# so that I can continue to contribute to the dark porting effort.

My first problem was I was trying to use the Paket package manager which is in use in dark, but for some reason I could not get any of the installed dependencies to be recognized. I randomly got it working in one project when I saved and re-opened a file, but then when I started a new project the same trick didn't work.

Needless to say I have no idea what I am doing. After spending way too much time troubleshooting this, I just switched back to the built in package manager from the dotnet CLI which uses nuget. This got me to the point where I was able to at least load and recognize the dependency in my F# code.

Sadly, I was not able to get this to actually work. I think the main problems is that I don't really understand how to use .NET objects from within F# and all of my code, while syntactically correct, looks like object oriented F# (which I guess is kind of a thing, but not really).

The good news is that I am sure I will figure this out given enough time, so onwards for now.

Using Skills

2021-03-25 ][ Tags: F# dark

I've been feeling a little demotivated lately because I have not applied my Computer Science skills as much as I want to in a long time. I get a lot of satisfaction out of the work that I do but I don't always have the opportunity to grow my technical skills.

A few weeks ago I discovered the OSSU Computer Science curriculum and I started working my way through some of the courses because I seem to have forgotten half of the things that I learned in college. This exercise was worthwhile because I remember more that I expected and have been more inspired than ever to actually do something with the knowledge that I have.

Earlier this week I read Paul's blog post about porting dark from OCaml to F#. I forked the repo and started poking around to see if there was something I could do with my new found inspiration.

After a stumbling through a few things while getting started, I am really happy that I was able to make a small, but useful, contribution to the porting effort.

I went from not knowing OCaml, F#, or dark to shipping a PR in two days. I still don't know OCaml, F#, or dark but I am optimistic that I can continue to figure things out. :)