TIL: Creating tables without primary keys CAN cause updates and deletes to fail in Postgres
A long time ago, I read in a medical book that One can learn about a system when things go wrong. So diseases are a good way to learn more about how the human body functions. That sentence stuck with me and this is about a story where someone made a mistake and learned something (someone, not me, I don’t make mistakes). It was friday afternoon (why do all tech disaster stories start on friday?...
What makes frontend development tricky
Preface This blogpost took over a month to write, it’s what I like to call exploratory writing where I explore some ideas that I have, or a new topic that I don’t know about and share it with you. It isn’t as polished as I’d like it to be. I also need to find a better way to present UI code, like having a live UI to interact with. The writing is quite long, there is a lot of code, but hopefully you’ll make it through....
Petri Plates to Parentheses: How I Became a Clojure Engineer
Exactly a year ago (15th December 2021), I was sweating bullets because it was my first day at my first ever tech job. All I could think of was “They made a mistake and haven’t realized it, they’re going to find out that I can’t really code”. But wait, how did I get here? Just a year ago, I was in a lab, waiting for the autoclave to finish, so I could make my plates and go home (autoclaves are used to sterilize lab equipment)....
Learning to walk with Clojure
Introduction This is a blogpost on how to use clojure.walk. clojure.walk is incredibly powerful and definitely worth investing time into. We’ll first look at some simple examples to get a feel for the functions and then I’ll demonstrate its power by walking through a problem and showing two solutions, one without clojure.walk and one with. I know the title says ‘learning to walk’, but by the end of the post you will know how to fly....
ELI5: Clojure's Iteration function
I’m going to try to explain in the simplest way how clojure’s iteration function works. It’s hard to discern how it works by reading the documentation (atleast the first few times). One of the most common use cases for iteration is making paginated api calls. A paginated api call usually returns two important data points, the actual data and a cursor which is used to fetch the next set of data points from the sequence....
How to run tests in clojurescript
This is a stupid simple guide to setting up clojurescript tests. This was written out of sheer frustration at the lack of a simple guide to run cljs tests. This will not be a guide about the various configurations you can run tests with, or the various ways to run cljs tests or any of the fancy stuff. This is a guide I wished I had when I was trying to setup clojurescript tests....
Writing Transducer Friendly Code
Introduction Clojure Transducers are a thing of beauty. They maybe hard to wrap your head around the first time, but are a joy to work with when it clicks. I’m not going to cover Transducers in this post, you can watch Lamdba Island’s video on transducers. All that you need to know is transducers are FAST! With a small change in your code, you can get a performance boost for free....
Understanding Bitemporal Data
What is bitemporal data? Bitemporal Data is data that has two time components associated with it. Data in the real world is immutable, bitemporal data is how we can capture this nature of data in our databases. Understanding uni-temporal data I am going to lay out some statements. The pyramid of Giza is the tallest man made structure. The Eiffel tower is the tallest man made structure. The Empire state building is the tallest man made structure....
The problem with python's map and filter...
… and how we might fix it. This is NOT a hate post. Let me say that again, This is NOT a hate post! Python is a fine language and it was my first programming language. Like the initial stages of falling in love with someone, you can’t see the flaws, the same was with python :) But as time goes by and the initial limerance fades, you start seeing the flaws....
Macrobrew: Clojure macros distilled
I first read about the legendary lisp macros in Paul Graham’s essay, and since then my whole journey of learning lisp has been driven by a desire to fully understand the power of macros. If you have not heard about the power of lisp macros, here’s a quote from one of the creators of Scheme (a lisp) that captures the essence of this power. If you give someone Fortran, he has Fortran....
Recursion is recursion is recursion is...
Defining recursion in terms of itself is an old joke among programmers. Despite the fact that it frustrates a lot of new-comers, we don’t change it. I like to define recursion as “Iteration for the cool kids”. I don’t mean this in a snobbish, let-us-exclude-the-for-loopers kinda way, but rather in a tone of appreciation. Recursion is an elegant way of doing things. Recursive alogrithms are concise, have less noise and have immutability baked in (always a plus)....
Clojure Tutorial for Beginners 1
Welcome, young lisper. I see you have heard the summons from the mystical forces. Prepare yourself for a journey like no other. Your view of programming shall change, and change for the better. You must shed your past beliefs and practices. This is a new path, one that bears little resemblance to the paths you have trodden before. And that is a good thing. Initiation rites You have two options - either use an online one-click setup or bite the bullet and install clojure and other tools on your local machine....
Hi Hugo, Bye Django
Introduction As you can see, there have been some (drastic?) changes to this site. It is much faster, the design is sleeker, and it looks like a completely different site. I can’t take credit for any of that. Except for the tiny green lowercase a favicon on top. My previous site was built with django, and I was running into some performance issues, I was about to look into caching mechanisms, and optimizing sql queries (requesting the front page resulted in 28 sql queries, tf?...
Classes are dictionaries draped in syntactic silk.
In this post, we are going to see how we can implement classes if python didn’t come with a class construct, read till the end if you’d want to know why I put you made you go through all this pain fun😉 What the heck is a Class? There are a lot of philosophical discussions about what classes are but I’m not concerned with that. In the simplest terms, a class is an entity that has data and functionality related to that data, these are called attributes and methods....
Fold is gold: understanding reduce
Introduction reduce or foldleft is a very powerful function, but it can be quite tricky to understand and use. In fact, I used to think that reduce was an obscure function, that reduced (hehe) the readability of a program. If you ever want to make it as a functional programmer, understanding reduce is as important as important as knowing how to reverse linked list. I’m joking, knowing how to reverse a linked list is not that important, and it can be done with reduce!...
Understanding partial functions
Welcome to the land of contrived examples and imperfect metaphors. Today we will be visiting a store called the five-item store. You’re only allowed to buy five items, no more, no less. The moment we enter the store, a cashier sees us and begins tailing us, and he keeps repeating “give me your items for so that I can make a bill” over and over again, so we just pick up an item and give it to him, and he shrieks and says “give me all five at the same time or none at all....
How to use timeit and pretty timeit
Here’s the situation, you have two algorithms in front of you, and you want to see which one is faster. Suppose we wanted to see what’s faster for constructing a list: a for loop, or a list comprehension. A simple solution might look like this. import time def number_list_1(count_up_to): lst=[] for i in range(count_up_to): lst.append(i) def number_list_2(count_up_to): lst=[i for i in range(count_up_to)] if __name__=="__main__": import time start = time.time() number_list_1(10000) end =time....