Fetching Blockchain Data With Hyperscript

I’ve been getting more and more into web development lately. It didn’t interest me too much in the past because I could never wrap my head around JavaScript despite having finished multiple Udemy courses on JavaScript and React. I feel like my personality is just at odds with how the JavaScript web development ecosystem is structured – it’s just too complex and chaotic, and it doesn’t have to be.

Anyway, I do most of my software development (if you can call it that) in Python. Until recently, most of the stuff I was developing was backend only – APIs, trading bots, etc. At some point, I heard about HTMX and hyperscript on a podcast, where it was being pitched as a way to do modern frontend development without having to write a single line of JavaScript.

As a chronic avoider of JavaScript, HTMX and hyperscript instantly caught my attention. In a nutshell, HTMX lets you send swappable HTML fragements from a backend server to a frontend, while hyperscript lets you create client-side interactivity with a natural language syntax.

To get a sense of what HTMX can do, check out this ICON blockchain tracker I’ve been working on. It’s still in active development, so some pages may look funny or break completely. The stack I’m using for the tracker is FastAPI, HTMX, TailwindCSS, and a little bit of hyperscript here and there. It’s pretty amazing to me that in 2022, it’s possible to develop something like this without writing any JavaScript. I know this way of doing things is fringe and contrarian, but it really brings me joy.

Before you go, click the hyperscript-enabled button below. It makes a request to a blockchain API and fetches a few block hashes – no JS required. Open up your web inspector if you’re curious as to how it works.

How to Use Python to Get the Number of Commits to a GitHub Repository

Recently, I’ve been working on a page to track GitHub activity for ICON-related repositories. The page has a component that displays every commit made to the tracked repositories. This component is powered by a background service that scrapes GitHub’s API for new commits every few minutes, and stores new commits in a MongoDB database.

As you can imagine, this task is fairly resource-intensive (especially for repos with a large number of commits) because GitHub only displays up to 100 commits on each API call. So, scraping commit data from a repo with 5,000 commits would require 50 API calls.

To make things a bit more efficient, I added some additional logic that queries the database for all commits to a repo, queries the GitHub API for the total number of commits, and compares the two numbers. If the two numbers are equal, the background service can just skip the resource-intensive API calls for the given repo.

Here’s a simplified version of the function I wrote to get the number of commits to a GitHub repo:

import requests
from urllib.parse import parse_qs, urlparse

def get_commits_count(self, owner_name: str, repo_name: str) -> int:
    """
    Returns the number of commits to a GitHub repository.
    """
    url = f"https://api.github.com/repos/{owner_name}/{repo_name}/commits?per_page=1"
    r = requests.get(url)
    links = r.links
    rel_last_link_url = urlparse(links["last"]["url"])
    rel_last_link_url_args = parse_qs(rel_last_link_url.query)
    rel_last_link_url_page_arg = rel_last_link_url_args["page"][0]
    commits_count = int(rel_last_link_url_page_arg)
    return commits_count

Switching Back to Cloudflare Pages

Back in December 2020, I tried out Cloudflare Pages for the first time during its public beta. After a few days of trying to get it to work with my blog, I gave up and reverted back to the always trusty Vercel.

Long story short, Cloudflare Pages was still very new at that point and there were some compatibility issues with a few of the larger images on my blog. Also, site builds were taking upwards of 10 minutes on Cloudflare, versus 1-2 minutes on Vercel.

Recently, I decided to take a look at Cloudflare Pages again because of Imgix’ new pricing model. I used Imgix to generate different sized variants of images on my blog because I don’t like the WordPress model of storing multiple sizes of the same image locally – it’s a waste of space. Imgix used to offer a cheap plan with generous limits, and my monthly bill never surpassed $8. The new pricing model includes a free plan that supports 1,000 origin images and unlimited transformations. Unfortunately, I don’t qualify for this plan because I have too many images on my blog.

The funny thing is I was actually grandfathered in on the old plan, but I wanted to take advantage of the two origin sources offered on the new free plan. After switching to the new plan, I was excited to reduce my monthly costs for hosting this blog. A few days later, I got a notification that I had exceeded 1,000 origin images and Imgix would no longer serve new images unless I upgraded to a paid plan – the cheapest of which is $75/month.

Here’s a breakdown of Imgix’ new pricing model:

  • Free ($0/month) – 1,000 origin images, 2 sources
  • Basic ($75/month) – 5,000 origin images, 5 sources
  • Growth ($300/month) – 25,000 origin images, 10 sources

To me, this pricing model feels weird because $0/month to $75/month is too big of a jump. I’d love to see a $15-$20/month “Creator” tier that offers 5,000 origin images and one source because I get the feeling that photography-centric bloggers like me don’t really care about the number of sources – we just need support for a lot of images.

At this point, I had two options:

  1. Reduce the number of images on my blog.
  2. Find a different provider for image resizing.

Option 1 obviously wasn’t happening, so I started looking for a new provider. After exploring various options, I ended up going with the Image Resizing feature that’s included with Cloudflare’s $20/month Pro Plan. I didn’t mind the $20/month fee because it’s a whole lot cheaper than paying $75/month to Imgix for image resizing ONLY.

Here are a few of my favorite features on the Cloudflare Pro plan:

  • Dynamic image resizing
  • Image optimization with Cloudflare Polish
  • Built-in web analytics (this allowed me to get rid of my $14/month Fathom Analytics subscription as well)
  • Support for Automatic Signed Exchanges
  • Super fast global CDN

While migrating my image resizing stack to Cloudflare, I decided to give Cloudflare Pages another shot as well. I’m happy to report that the Pages product has been polished (no pun intended) significantly since I last tried it. After linking my blog’s GitHub repository to Cloudflare Pages, it was able to build and deploy the site in less than two minutes with zero issues. Best of all, I ran a few page speed tests and found that Cloudflare Pages is slightly faster than Vercel and Netlify.

I’m glad I was able to move my entire stack (DNS, hosting, and image resizing) to Cloudflare. If you use a static site generator like Hugo to power your blog, I highly recommend hosting on Cloudflare Pages and taking advantage of the powerful features on Cloudflare’s Pro Plan as well.

What ICON 2.0 Means for the ICON Ecosystem

ICON 2.0 is a monumental shift for the ICON blockchain and the broader ecosystem. With ICON 2.0 comes a host of new technologies like BTP for interoperability, Java SCORE support, a completely new core blockchain engine, an EVM-compatible sidechain, and more. In this article, we’ll take a look at ICON 2.0 from a technical perspective to see what kind of potential impact it may have on ICON adoption.

Continue Reading →

How to Rebalance Loans and Retire bnUSD on Balanced

Recently, there’s been a lot of buzz in the ICON community regarding rebalancing of loan positions on Balanced. A rebalance happens when ICX collateral is sold for bnUSD to pay off a portion of a loan – this process can also be referred to as “retirement of bnUSD”. It’s important to note that rebalancing has nothing to do with how close your loan is to the reward threshold. Instead, rebalancing is used to keep bnUSD pegged to 1 USD as close as possible, and it occurs when there is an economic incentive to do so (e.g. the difference between 1 bnUSD and 1 USD crosses a risk threshold).

Continue Reading →

Jason Fried Apologizes on Behalf of Basecamp

Jason Fried:

Last week was terrible. We started with policy changes that felt simple, reasonable, and principled, and it blew things up internally in ways we never anticipated. David and I completely own the consequences, and we’re sorry. We have a lot to learn and reflect on, and we will. The new policies stand, but we have some refining and clarifying to do.

Honestly, I didn’t think we’d ever see an apology from Basecamp because there’s nothing worthwhile to apologize for, and apologizing to the woke left is something that should be avoided at all costs.

  1. Basecamp is a for-profit business that pays employees to perform work. If Basecamp feels that political discussions at work reduce productivity and increase hostility, asking employees to refrain from such discussions is reasonable. Asking employees to focus on work at work is not immoral, racist, privileged, (insert woke buzzword here), or something to apologize for.
  2. I’m not sure who the target audience for this apology is. The offended parties will certainly take this apology and put some woke spin on it to make Basecamp look even worse.

« Permalink »

The Basecamp Drama Continues

DHH:

The following account is my response to the initial disclosure and apology made by the person leading the team that had maintained the list over the years. That initial disclosure had some inconsistencies and omissions which led to an exhaustive investigation. It also included the arguments and graphics that, as Casey reported, positioned the existence of the list on a pyramid of escalations that can lead to genocide.

DHH’s recent series of posts addressing the Basecamp drama is worth a read, along with Casey Newton’s newsletter on the topic.

I’m probably in the minority, at least the vocal minority, but I think Basecamp’s move to discourage political discussions on internal company channels is completely reasonable.

Employees are paid to work on tasks defined by the company, and the work is 100% contractual. As companies grow and change in response to both internal and external influences, workplace rules may change. In this case, Basecamp has decided that it’s no longer appropriate to engage in sensitive political discussions at work. It’s probably a response to the current political climate, and I don’t blame them for this decision.

Unsurprisingly, most people on Twitter think Basecamp has done something wrong. To me, it’s ridiculous that the idea of a business asking employees to focus on work at work has somehow turned into a controversial s***storm that requires a PhD in wokeness to fully understand. Again, Basecamp is a for-profit business, and they have every right to take steps to ensure that employees are distracted as little as possible during work hours.

Stuff like this is exhausting to write about, so here are a few random thoughts.

  • People who view this situation as “white men oppressing employees’ rights to free speech” should take a long, hard look in the mirror. There’s no oppression going on here. Woke folks choose to view the world in a binary lens without nuance and situational context. Situational context is very important in the real world. A high school teacher asking students to be quiet and pay attention is not oppression. Basecamp asking paid employees to refrain from engaging in political discussions on company time and in company channels is not oppression. It’s only oppression (maybe) if you take the situational context out of the equation. Basecamp’s actions here are not concerning in the least. What is concerning is people’s collective inability to recognize situational nuance and think critically before jumping on the bandwagon to score wokeness points.
  • I got rid of my HEY account last year, but I’m thinking of re-subscribing. I have enormous respect for Jason and DHH’s decision to double down on business, and I think it’ll act as a catalyst for other founders and executive teams to do the same. The current political climate is overheated, and it makes complete sense to de-risk by reducing political talk in company channels. Employees are still free to talk about whatever they want on non-company channels. There is no oppression going on here.
  • I have to wonder how all these Basecamp critics would run a multi-million dollar business. As founders, Jason and DHH have the most to lose out of anyone at Basecamp. To think that they made such a decision with ease, especially at a time like this, shows a distinct lack of empathy. Oh wait, Jason and DHH are both well-to-do white men, so I guess they don’t need any empathy. But really though, what would you do as a founder of a successful company in this political climate? Would you choose to ignore political discussions that trigger employees, causing them to be less productive, or would you stop political discussions from happening so people can focus on the work they’re being paid to do?

« Permalink »

Diversity and Inclusion in a Decentralized World

Diversity and inclusion (D&I) in the workplace is something I’ve been thinking a lot about recently. I think my views on D&I are not as liberal as many of my friends and coworkers. For a workplace that follows traditional corporate standards, I think designing a diverse environment is usually an overall net positive as long as it’s not performed through the lens of a rigid framework.

So, I think D&I is nice to have in a traditional workplace, but I’m not the type of person to push the idea on everyone I know. In the WordPress space, it’s common to see certain individuals go on and on (literally everyday) about diversity, underrepresentation, marginalization, and how white people should always keep their “privilege” in check (or something like that).

It makes me wonder if these people are taking the whole diversity thing a little seriously. Really, I don’t think talking about how marginalized and underrepresented you are every single day is good for your mental health. I’ll be honest – as someone who is apart of one of these so called marginalized and underrepresented groups, I’ve never come across a negative workplace scenario that was caused by my race or ethnicity. Does this mean I’m “privileged”, or is the whole D&I conversation just turned up to 11 right now?

My views on D&I are the way they are because I’ve come to the conclusion that it’s not a necessity for every single workplace environment. D&I is not a requirement to be productive, and it’s not a requirement to build amazing products. Hear me out before you call me privileged or racist.

Working in blockchain is amazing. It’s what I spend all my free time on, and lack of purposeful D&I is one of the reasons why I love it so much. I’ve never met most of my colleagues in the blockchain space, and I don’t even know most of their names. We mostly communicate through Telegram, Slack, and occasional audio calls, and we get work done.

In this context, there is no D&I mental overhead because it’s completely abstracted out of the equation. It’s near-impossible to distinguish someone’s race from text-based communication. Since people usually prefer to stay anonymous in blockchain, “real” profile pictures are pretty rare. I’ve been working in blockchain for three years now. In that time, one guy who I thought was Asian ended up being a white dude from Amsterdam. Similarly, someone else who I thought was a white guy living in the USA ended up being an Asian guy living in the Philippines. Best of all, no one (including me) gives a s*** about any of this. People are judged solely based on their work ethic and the skills they bring to the table, and that’s how it should be.

Abstracting away D&I completely is, of course, only possible in an anonymous or pseudo-anonymous work environment. So, this begs the question whether this kind of work environment is superior to the traditional corporate workplace where a huge amount of emphasis is placed on learning more about the backgrounds of your colleagues. Interestingly enough, I feel closer to my colleagues in blockchain than my colleagues at my day job. This makes me wonder whether concepts like HR protocols, fear of coming off as “privileged”, and other sorts of virtue signaling constructs actually prevent colleagues from forming strong friendships in an efficient manner.

It’ll be interesting to see if “anonymity in the workplace” spreads to other industries over the coming years. For this kind of workplace environment to become commonplace, there needs to be a huge shift in how people think about and design corporate structures. I think DAOs (decentralized autonomous organizations) are a step in the right direction.

The idea here is instead of motivating people to work via a “corporate ladder” backed by accepted rules and behaviors, give people a direct stake in the organization via a token and design the governance system in a way that incentivizes everyone to act in a productive manner.

I think the D&I trend over the past few years is the latest version of “social glue” that allows traditional companies to continue functioning with respect to current events. Social glue is important because the governance structure of most companies is not set up in a way that fairly rewards those who contribute the most, and punishes those who don’t do a good job – this is because social norms take precedence over everything else in a non-anonymous environment. Thus in order to keep a company together, tools like D&I need to be introduced to prevent the social fabric from tearing.

My grand thesis is that as we evolve into a society that truly values privacy, the inefficiencies of traditional corporate structures will become more and more apparent. At the same time, I think decentralized and pseudo-anonymous work will become more popular.

Let’s see what happens.