Posts
Geo Routing (Craigslist Example)
Geo-Routing (Case Study on Craigslist) When you open craigslist.org it does a couple of redirection before finally landing on the subdomain closest to your city. Having separate sub-domain and listings for those particular cities is partly how it seems to handle the distribution of the content. (making it more scalable)
Give it a try: https://craigslist.org
Here is the journey of the request:
curl -I craigslist.org HTTP/1.1 301 Found Location: https://www.craigslist.org/ redirected to https://www.
read morePosts
ChatGPT Notebook - A Chrome Extension
Trend of LLM Large Language Models continue to find new use cases. Though they started off as smart chatbots developers are using the open source models (thanks to corporates like Meta who open source models and no thanks to OpenAI) and fine tuning them to be used for specific domains. It’s so obvious that in the future these LLM are going to be our personal copilot, our wingman each tailored to each individual.
read morePosts
Literate Programming
Literate Programming Python notebooks are so ubiquitous in the Machine learning community. All the cloud providers have dedicated services to run these notebooks: Jupyter on AWS, Jupyter on Azure, and Google Collab. These are popular largely because of how we can accommodate both code and instructional text in the same file. With each individual cell as an executable code block or a properly formatted markdown text, this makes it much easier to present information, document the information and make it a better educational material.
read morePosts
Quirks of Query Planner
Query Planning Every SQL database (postgres,mysql) has a query planner built into it whose job is to find the best strategy to come up with the results given the query, its predicates and other expressions. Following examples are from postgres where I explore around how query planner makes its decision based on the data size in the table and the state of the database even in the presence of index.
read morePosts
Using taskwarrior to stay disciplined with side projects
Taskwarrior Taskwarrior is an OSS CLI (to make it fancier, let’s call it TUI - terminal UI) based task manager. I have been using it for sometime and it works great for my use case.
My Earlier Post on setting GUI notifications
I wanted some discipline in progressing with my side projects most of which are on github and here’s what I did:
set up a script which overrides task warrior’s data directory to current directory if it’s a git repository, this is so that I can segregate my todo tasks
read morePosts
SQL Injection - 101
SQL Injection Starting off with one of my favorite xkcd comic
SQL Injection is a way where a user is able to send some ‘code’ as part of the input data to the server all the way back to the database. (UI layer doesn’t sanitize/validate, API layer let’s the malicious ‘code’ reach the database because it’s not mindful in how to separate ‘query’ and ‘data’).
Taking the example from xkcd:
read morePosts
Currying in functional programming
Currying Currying is an idea of decomposing a function and making the expression more clearer. (Note: it’s just expression decomposition and not execution)
Example In Go: package main import ( "fmt" "strings" ) func main() { fmt.Println(someComplexOperation("hello", "there", "programmer")) fmt.Println(someComplexOperation("hello", "there", "manager")) fmt.Println(someComplexOperation("hello", "there", "CEO")) // Currying this function // By looking at the fuction we see that it can be decomposed, first step of computing from first 2 arguments // can be done and reused.
read morePosts
Loop Iterator variable scope in golang
Per Iteration Vs Per Loop In most of the languages, the loop variable (iterator) has a per iteration scope, meaning in each iteration a new copy of that variable is made. But in golang it’s the same variable that has the scope throughout the loop. All the changes (increments) apply to the same placeholder and if you are temporarily capturing them and spawning go routines or creating a function placeholder (for later execution) you start to see unexpected consequences.
read morePosts
Struct Embedding, JSON Encoding in GO
Embeding a struct (just writing the type) creates a “has a relationship” with the parent. If the child implements any interface parent can directly invoke those methods. If there are more than one embedding and they implement a common method it’s okay as long as we don’t attempt to directly invoke it on parent (trying to do so results in compilation error - ambiguous selector) While encoding json (marshalling), encoder internally checks if the type implements json.
read morePosts
A case of slow loading zsh
I have been using zsh (Z-shell) for a long time. Recently it came to my attention that opening a new terminal was taking about 2-3 seconds which is quite a long time.
Just to rule out some other reasons, I switched my default shell to bash and saw if it was still slower and turned out that was not the case.
Changing default shell chsh -s /bin/bash Normally all shells load up some configuration, aliases, etc while opening a session, .
read more