Books I read and links to my reviews(not exhaustive) starting from 2025. Mar, 2025 In the Margins: On the Pleasures of Reading and Writing, Review Martyr! Feb, 2025 Chronicle of an Hour and a Half, Review Jan, 2025 Greek Lessons, Review| Technical Ramblings
These are some of the blog posts and links I enjoyed reading in the reverse chronological order| kracekumar.com
About| kracekumar.com
In 2024, Large Language Models (LLMs) and Generative AI(GenAI) exploded at an unimaginable rate. I didn’t follow the trend. Currently, there is a news every day on new models. Also, the explosion of models reached a stage where local MacBooks can run a decent enough model. I want to have local model with a decent UI support through web or terminal that provides clean user interface. I stumbled upon open-webui. Open WebUI is an extensible, feature-rich, and user-friendly self-hosted WebUI de...| Posts on Technical Ramblings
On saturday night, I want to work on a side project. To find a name for the project and I wanted to create an Github organization in the same name. I started trying out the name one after the other, all the names were taken and thought about writing small script in ruby. Then from nowhere I decided to let chatgpt to write the code for me. In this blog post, I’ll share some of the code generated by chatgpt for the checking whether a profile name exists in the Github with increasing complexity.| Posts on Technical Ramblings
The problem When the web service latency increases, the first suggested technique is to cache. The cache is a good solution when your system is a read heavy system. The common technique is to cache the frequently used objects. The method generally reduces the latency, but doesn’t help much for tail latency (p99). The paper “Tail Latency Aware caching - Dynamically Reallocating from cache rich to cache poor” proposes a novel solution for maintaining low request tail latency.| Posts on Technical Ramblings
Dia Duit Dublin, Bye Bengaluru TL;DR: After working for a decade and a year in Bengaluru, I decided to join Stripe in Dublin, Ireland as a software engineer. When I was in final year of college, I had to choose job location preferences over Chennai and Bengaluru. I choose Bengaluru for two reasons - startups and weather. After working a decade and a year in Bengaluru over seven companies, I decided to leave the startup scene, city, and the country.| Posts on Technical Ramblings
Last week, May 2-6, 2022, I attended Rafting Raft workshop by David Beazley. The workshop focussed on building a raft implementation and it was intense and exhausting. A few folks had asked me about the workshop and how it works. The post focuses on what happens before and during the workshop, so future attendees can decide. Day -43 Someday when you’re contemplating attending the workshop, you register on the website. You get a confirmation email from David Beazley to confirm your availabil...| Posts on Technical Ramblings
TL:DR Pyinstrument is a call stack sampling profiler with low overhead to find out time spent in your Django application. QueryCount is a simplistic ORM query count middleware that counts the number of ORM queries, finds duplicate queries, and prints them in the terminal. Django Silk is an extensive Django profiler that records the entire execution, SQL queries, source of origin, and persists the recordings. The complete Django profiler. 🔬 What’s Profiling? 🔬 Profiling is a dynamic pr...| Posts on Technical Ramblings
HTTPie is a command-line utility for making HTTP requests with more straightforward syntax(controversial, I agree). The interesting feature is --offline flag which prints HTTP raw request text. The client sends the HTTP request to the server, and the server responds to the request. It’s an alternate to curl. HTTP Syntax HTTP Flow and syntrax from Wikipedia. A client sends request messages to the server, which consist of a request line, consisting of the case-sensitive request method, a spac...| Posts on Technical Ramblings
Recently, I gave a talk, Type Check your Django app at two conferences - Euro Python 2021 and PyCon India 2021. The talk was about adding Python gradual typing to Django using third-party package Django-stubs focussed heavily around Django Models. The blog post is the write-up of the talk. Here is the unofficial link recorded video of the PyCon India talk. Here is the link to PyCon India Slides. The slides to Euro Python Talk (both slides are similar).| Posts on Technical Ramblings
PhonePe recently released Pulse repo from their payment data. It was hard to get an overview of the data without doing some data transformation. The data is eight levels deep, nested, and multiple files for similar purpose data. Hard to do any command-line aggregate queries for data exploration. It’s hard to do any analysis with 2000+ files. So I created an SQLite database of the data using python sqlite-utils. The SQLite database aggregated data and top data in 5 tables - aggregated_user, ...| Posts on Technical Ramblings
Quite often, as a programmer, I learn something new. Some are utilitarian; some are philosophical; some are opinions in programming. I want to document these learnings for later use and also to remember. So I’m starting a new site, til.kracekumar.com, to demonstrate this learning. So far, there are six posts. The inspiration comes from Simon Willson’s TIL website. Why the new site? Two reasons I’m planning to write often; sometimes, the post will fit in just two tweets. I don’t want t...| Posts on Technical Ramblings
Python 3 introduced type annotation syntax. PEP 484 introduced a provisional module to provide these standard definitions and tools, along with some conventions for situations where annotations are not available. Python is a dynamic language and follows gradual typing. When a static type checker runs a python code, the type checker considers code without type hints as Any. def print_name(name): print(name) planet: str = "earth" In the above example, the name argument type hint will be Any sin...| Posts on Technical Ramblings
The last post covered the structure of Django Model. This post covers how the model field works, what are the some important methods and functionality and properties of the field. Object-Relational Mapper is a technique of declaring, querying the database tables using Object relationship in the programming language. Here is a sample model declaration in Django. classQuestion(models.Model):question_text=models.CharField(max_length=200)pub_date=models.DateTimeField('date published') Each class ...| Posts on Technical Ramblings
Django ORM hides a lot of complexity while developing the web application. The data model declaration and querying pattern are simplified, whereas it’s structured differently behind the scenes. The series of blog posts will explain Django ORM working(not just converting Python code to SQL), model declaration, querying (manager, queryset), supporting multiple drivers, writing custom queries, migrations etc… Consider a model definition from the Django tutorial. fromdjango.dbimportmodelsclas...| Posts on Technical Ramblings
The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text. Uses include: data cleaning and transformation, numerical simulation, statistical modeling, data visualization, machine learning, and much more. The definition copied from the official website. It’s becoming common to use Jupyter notebook to write books, do data analysis, reproducible experiments, etc… The file produced ...| Posts on Technical Ramblings
Pytest library provides a better way to write tests, run the tests, and report the test results. This post is a comparison between the Python unit test standard library and pytest features and leaves out other libraries like nose2. TL;DR Single assert statement(assert a == b) over 40 different assert methods(self.assertEqual, self.assertIsInstance, self.assertDictEqual) Better and detailed error messages on failure. Useful command line options for reporting, discovering, and reporting tests l...| Posts on Technical Ramblings
Introduction The blog post is a write up of my two talks from PyGotham and PyCon India titled, Build Plugins with Pluggy. The write-up covers a trivial use-case, discusses why a plugin-based architecture is a good fit, what is plugin-based architecture, how to develop plugin-based architecture using pluggy, and how pluggy works. Link to PyCon India 2020 Talk Trivial Use Case For the scope of the blog post, consider a command-line application queries gutenberg service, processes the data, and ...| Posts on Technical Ramblings
Datasette python library lets publishing a dataset as a SQLite database and inspects them using a web browser. The database can store text, numbers, arrays, images, binary data, and all possible formats. datasette-render-images lets you save the image in the database and render the image using data-uris. Sometimes, while publishing the dataset, you may want to store the images in a separate directory for various reasons and include the relative path to the database’s images in the table.| Posts on Technical Ramblings
To find a labeled data for Tamil NLP task is a difficult task. Some papers talk about Tamil Neural Translation, but the article doesn’t release code. If you’re working part-time or possess an interest in Tamil NLP, you have a tough time finding data. When I was looking for labeled data for simple sentiment analysis, I couldn’t find any. It’s understandable because there is no one working on it. So I decided to build my dataset. Twitter seemed a perfect place with lots of data. I scrap...| Posts on Technical Ramblings
Introduction A single test case follows a pattern. Setup the data, invoke the function or method with the arguments and assert the return data or the state changes. A function will have a minimum of one or more test cases for various success and failure cases. Here is an example implementation of wc command for a single file that returns number of words, lines, and characters for an ASCII text file.| Posts on Technical Ramblings
The data is a representation of reality. When a value is missing in the piece of data, it makes it less useful and reliable. Every day, articles, a news report about COVID-19 discuss the new cases, recovered cases, and deceased cases. This information gives you a sense of hope or reality or confusion. Regarding COVID-19, everyone believes or accepts specific details as fact like mortality rate is 2 to 3 percent, over the age of fifty, the chance of death is 30 to 50 percent. These are establi...| Posts on Technical Ramblings
A few days back, Keras creator, Francois Chollet tweeted A Keras/TF.js challenge: make a model that processes a webcam feed and detects when someone touches their face (triggering a loud beep).“ The very next day, I tried the Keras yolov3 model available in the Github. It was trained on the coco80 dataset and could detect person but not the face touch. V1 Training The original Keras implementation lacked documentation to train fromscratch or transfer learning. While looking for alternative ...| Posts on Technical Ramblings
Kashmir is under lockdown for more than 200,200,200,200,200,200,200,200,200,200, 200,200,200,200,200,200,200,200,200,200, 200,200,200,200,200,200,200,200,200,200, 200,200,200,200,200,200,200,200,200,200, 200,200,200,200,200,200,200,200,200,200, 200,200,200,200,200,200,200,200,200,200, 200,200,200,200,200,200,200,200,200,200, 200,200,200,200,200,200,200,200,200,200, 200,200,200,200,200,200,200,200,200,200, 200,200,200,200,200,200,200,200,200,200, 200,200,200,200,200,200,200,200,200,200, 200,20...| Posts on Technical Ramblings
How does one find out what network calls, browser requests to load web pages? The simple method - download the HTML page, parse the page, find out all the network calls using web parsers like beautifulsoup. The shortcoming in the method, what about the network calls made by your browser before requesting the web page? For example, firefox makes a call to ocsp.digicert.com to obtain revocation status on digital certificates. The protocol is Online Certificate Status Protocol.| Posts on Technical Ramblings
Kashmir is locked down without the internet for more than 167 days as of 19th Jan 2020 since 5th Aug 2019. The wire recently published an article wherein the Government of India whitelisted 153 websites access in Kashmir. Below is the list extracted from the document . The internet shutdown is becoming common in recent days during protests. Anyone with little knowledge to create a web application or work can say, every web application will make network calls to other sites to load JavaScript,...| Posts on Technical Ramblings
Data is crucial for all applications. While fetching a significant amount of data from database multiple times, faster data load times improve performance. The post considers tools like SQLAlchemy statement, SQLAlchemy ORM, Pscopg2, psql for measuring latency. And to measure the python tool timing, jupyter notebook’s timeit is used. Psql is for the lowest time taken reference. Table Structure annotation=> \d data; Table "public.data" Column | Type | Modifiers --------+-----------+----------...| Posts on Technical Ramblings
Debugging is a time consuming and brain draining process. It’s essential part of learning and writing maintainable code. Every person has their way of debugging, approaches and tools. Sometimes you can view the traceback, pull the code from memory, and find a quick fix. Some other times, you opt different tricks like the print statement, debugger, and rubber duck method. Debugging multi-processing bug in Python is hard because of various reasons.| Posts on Technical Ramblings
On day 2, I spent a considerable amount of time networking and attend only four sessions. Spotswap: running production APIs on Spot instance Amazon EC2 spot instances are cheaper than on-demand server costs. Spot instances run when the bid price is greater than market/spot instance price. Mapbox API server uses spot instances which are part of auto-scaling server Auto scaling group is configured with min, desired, max parameters. Latency should be low and cost effective EC2 has three types of...| Posts on Technical Ramblings
Root Conf is a conference on DevOps and Cloud Infrastructure. 2017 edition’s theme is service reliability. Following is my notes from Day 1. State of the open source monitoring landscape The speaker of the session is the co-founder of Icinga monitoring system. I missed first ten minutes of the talk.-The talk is a comparison of all available OSS options for monitoring, visualization. Auto-discovery is hard. As per 2015 monitoring tool usage survey, Nagios is widely used. Nagios is reliable a...| Posts on Technical Ramblings
The Culture Map: Breaking Through the Invisible Boundaries of Global Business is a book on cultural differences in communication by Erin Meyer. Last year, I spent three months in NYC. Whenever I entered food outlet or made an eye contact, all the conversation started with “How are you doing?”. I replied, “I’m good and how are you doing?”. Most of the times, I didn’t receive a response. It was a sign. Pedestrians smile at you if you make an eye contact in the US. This doesn’t hap...| Posts on Technical Ramblings
The book Software Architecture with Python is by Anand B Pillai. The book explains various aspects of software architecture like testability, performance, scaling, concurrency and design patterns. The book has ten chapters. The first chapter speaks about different architect roles like solution architect, enterprise architect, technical architect what is the role of an architect and difference between design and architecture. The book covers two lesser spoken topics debugging and code security...| Posts on Technical Ramblings
One Sunny Sunday morning one can get up and question their self-existence, or one can ask every few days or few months what am I doing at the current job? The answer will push you to a place you have never been. One can meticulously plan for extravagant programming tour or programmer’s pilgrimage for three months. Yes, that what my outlook of RC is! RC is a different place from a usual workplace, meetups, college or any educational institute. The two striking reasons are peers and social ru...| Posts on Technical Ramblings
Postgres supports JSON and JSONB for a couple of years now. The support for JSON-functions landed in version 9.2. These functions let Postgres server to return JSON serialized data. This is a handy feature. Consider a case; Python client fetches 20 records from Postgres. The client converts the data returned by the server to tuple/dict/proxy. The application or web server converts tuple again back to JSON and sends to the client. The mentioned case is common in a web application. Not all API...| Posts on Technical Ramblings
A simple question can open a door for new exploration. While I was at RC, I tweeted “Is there any meetup group similar to papers we love for discussing RFCS?”. In an interval of nine minutes, Jaseem replied: “Let’s start one :)” Is there any meetup group similar to @papers_we_love for discussing RFCs? — kracekumar (@kracetheking) November 30, 2016 Above discussion on Twitter, lead to a new focus group RFCS We Love in Bangalore by Nemo, Jaseem, Avinash and Kracekumar. The first mee...| Posts on Technical Ramblings
What is the Jupyter notebook? The Jupyter Notebook is a web application that allows you to create and share documents that contain live code, equations, visualisations and explanatory text. The definition is from the official site. I use IPython/Jupyter shell all time. If you haven’t tried, spend 30 minutes and witness the power! At times, I want to share some code snippet with folks in the same building during work, workshop or training. The Jupyter notebook configuration allows the user t...| Posts on Technical Ramblings
The Recurse Center is a free, three-month self-directed program for people who want to get better at programming. I attended fall batch 2 in 2016 from September to December. If you aren’t aware of Recurse Centre, take a couple of minutes to go through recurse.com and read the rest of the piece. Every day we open a significant amount of doors to get to desired places. Some doors are unique but look dull and plain, but the incredible universe behind the door hides excitement, adventures, gems...| Posts on Technical Ramblings
Grokking algorithm - An illustrated guide for programmers and other curious people is the book by Aditya Y. Bhargava about understanding algorithms. The book is different from other algorithm books. The book explains the chosen concepts with illustrated guide like cartoons, xkcd and doesn’t let the followers lost in the sea of mathematical formulas or procedure. The book discusses a handful of foundational topics on algorithms like Big O notation, Binary Search, Sorting, Recursion, Hash Tab...| Posts on Technical Ramblings
I was watching one of my favorite Tamil writer S Ramakrishnan’svideo about books. Somewhere in the middle of the talk, he suggests the audience to write down the list of books they read this year and share with others. Irrespective of how short or tall the list is, undoubtedly people will pick up from the list someday. I bought the idea and documenting the book list. English Read The 5 Elements of Effective Thinking Quiet: The Power of Introverts in a World That Can’t Stop Talking - The b...| Posts on Technical Ramblings
EDHT I continued to work on the project and added the few features. Data replication - One of the main features of DHT is replicate the data across a subset of nodes in the cluster. Remember not all nodes! Depending on the number of copies to store, say N, the data is stored in N - 1 nodes starting from the primary node in the anti-clockwise direction. Routing - Every node in the cluster has equal responsibility, and there is no master. For key metamorphosis the data is stored in the nodes n1...| Posts on Technical Ramblings
This week has mostly been calm and cold in New York. EDHT Distributed Hash Table implementation in Erlang is slowly coming along. The project now supports multi-node communication. The project uses bitcask which riak uses. Erlang’s Key/Value store data is local to the single process. Building Key/Value store from the ground up requires reinventing wheel and time consuming. The leveraging existing library made sense. Bitcask takes care of persisting the data to the disk and can access data w...| Posts on Technical Ramblings
This week I spent most of the time on working with Zulip, Erlang and EDHT. Zulip This week, we (Stan, Jennifer and I) continued efforts on implementing message reaction. We made decent progress and had a good create reaction frontend. During the journey, we discovered an interesting bug. Debugging the bug on production minified JS with the debugger was fun. We are close to completing the completing the initial version. It’s still a few days away from closure.| Posts on Technical Ramblings
This week has been quiet, bikeshedding, holiday week and unproductive week so far in RC. Zulip Zulip is a Python-based open source group chat. RC uses zulip for the internal chat. Unlike GitHub, zulip doesn’t support inline emoji reaction for messages. I am collaborating with Arpith and Stan Zheng to add the missing feature. The first time I came across the limitation of Django’s values method. If you’re considering setting up a group chat for your community or company, try out zulip!| Posts on Technical Ramblings
This week most of the time I spent learning Distributed Hash Tables and Erlang. That means I didn’t write a significant amount of code for the project. I am reading DynamoDB paper which is Distributed Hash Table and Distributed Key/Value store. Some implementation like etcd and consul provides Distributed Key/Value store but replicates all data across nodes. So those aren’t Distributed Hash Table. I am reading the one sections at a time. DynamoDB paper is the first technical paper reading...| Posts on Technical Ramblings
It’s common for developers to work on side projects. The reason why developers work on a side project is a long list of imaginable and unimaginable reasons. My main reason to work on a side project is to learn how things work or to build a utility program for use. One of my recent projects is to monitor the internet traffic and aggregate the traffic based on the domain name - bandwidth monitor. Before jumping into the code, I read a little bit about OSI Layers, TCP, UDP, IP and Ethernet pac...| Posts on Technical Ramblings
This week, I reached the first milestone of the project - imon which I worked on for past couple of weeks. imon is a command-line utility to record all network traffic and classify the data according to the domain name. Here is a high-level presentation of the project.I am looking for code review on the project and happy to answer any questions. I wrote a blog post about my experience with Rust. I am excited about the project and hope to keep working on it. If you have any comments on Rust or...| Posts on Technical Ramblings
When I was about to leave to RC in few weeks, wrote an E-mail to Puneeth asking for Do's and Don'ts at RC. One of the line in the mail said, Since you are a Python guy, don’t write any Python code while you are there. Do something completely different. I contemplated which language to choose. Other than Python, I knew a decent amount of Go-lang and Javascript. I previously attempted to learn rust but never dived deep into it. I reconsidered learning it and came up with the project idea.| Posts on Technical Ramblings
Time flies faster than you can perceive. The first half of twelve weeks experimental journey ends this week. This week was the last week for Fall 01, 2016 batch and my batch is due in next six weeks. I wish everyone in Fall 01, 2016 batch Good luck for their future endeavors. I made few friends, helped few people in their project; few helped me in my projects and a lot of unnoticed learnings.| Posts on Technical Ramblings
What can you do during acute inhuman soul-crushing conditions in life? Hope. This book is about “Hope.” - dopamine for life. Psychiatrist Viktor Frankl’s presents his life in Nazi death camps and learning for spiritual survival. The narrative is based on his experience and the experiences of others he treated later in his practice. The author aptly reiterated throughout the book “We cannot avoid suffering, but we can choose how to cope with it, and find a meaning to live.”| Posts on Technical Ramblings
I had a decent progress with my rust HTTP traffic monitor. I read a lot about the different type of packets like Ethernet Packet, IPv4 Packet, TCP Packet, UDP Packet, DNS Packets. I wrote a parser for Physical Layer packet, TCP Packet, UDP Packet, DNS Packet. The parser helped me understand a lot about rust functions, data types like array, vectors, string and string literal. I am not enjoying the relationship with rust lifetimes. Lifetime is getting harder for me to grok with nested struct...| Posts on Technical Ramblings
This week commenced with the second project at RC in rust. I am building a command line utility to monitor internet bandwidth consumption categorized by websites. I had a general idea of how to go about it and drew rough sketches. As a lot of people suggested me, I am fighting battles with rust compiler in a life time and borrowing. I hit my first road block with pcap library and here is the issue. I am using threads, socket in the application together (Tough battles at the same time!). So fa...| Posts on Technical Ramblings
Quiet: The Power of Introverts in a World That Can’t Stop Talking is an excellent book about introverts and what makes introvert an introvert. The book dives deep how different culture views introvert, analyses what intrigues introverts and in what circumstances they effectively work. The book makes a lot of parallel comparisons with extroverts. What intrigues extroverts and why introverts are good at solving complex problems. The book accounts for various behavior patterns like how introve...| Posts on Technical Ramblings
This week has been a mixed ride with the torrent client. I completed the two pending features seeding and UDP tracker. The torrent client has a major issue with downloading larger torrent file like ubuntu iso file. The client starts the downloads from a set of peers and slowly halts at sock.recv after exchanging a handful of packets. At this juncture CPU spikes to 100% when sock.recv blocks. Initially, the code relied on asyncio only features, now the code uses curio library. Next time you wr...| Posts on Technical Ramblings
This week, I made considerable progress on the BitTorrent client which I started a week back. The client is in a usable state to download the data from the swarm. The source code is available on GitHub. The project uses Python 3.5 async/await and asyncio. I presented the torrent client in RC Thursday five minute presentation evening slot. Here is the link to the slides. Here is quick video demo recorded with asciinema.| Posts on Technical Ramblings
The long awaited Recurse Center debut day, 26th Sep 2016 kick started with a welcome note by Nicholas Bergson-Shilcock and David Albert ; decorated by other events and activities to get to know the batchmates; the culture of RC and ended with closing note by Sonali Sridhar. At the end of the day, I had decided to build a BitTorrent client as a first project. I was at the crossroad to choose Python or Rust or Go for the project. After a quick chat with batch mate, I decided to write the BitTor...| Posts on Technical Ramblings
I’m attending Recurse Center fall'02, 2016 batch. I’m excited (yes, without emoticons) to be in RC and New York. RC is different from schools, boot camps, universities for various reasons. The two reason I like the most is “Never Graduate” and “self-directed learning.” A lot to learn from peers, experiments, and discussions. Next, 12 weeks will be intense and what can a programmer ask for more than time to solve problems and understand how things for. Now, I’m afraid, 12 weeks m...| Posts on Technical Ramblings
Road transport between Coimbatore and Bangalore is hit badly by fear, tension, security and protest. As of 18th Sep 2016, The current news is only two-wheelers are allowed to cross the Hosur border. The Tamil Nadu vehicles carrying vegetables, bananas, and other commodities are prohibited from entering Karnataka. Ordinary people travel till Hosur, cross the Border and walk for one or two kilometers to get a public transport and reach Bangalore. The another option is to take the train. My luck...| Posts on Technical Ramblings
Bangalore is called the Garden City of India. How often do you walk into a garden? I visit often. I envy you if you own a garden at home! Every day you can spot a lot of flowers and trees during transit to work, casual walk, etc … In the evening, trees welcome all passer-bys with chosen fallen flowers in the pathway. Especially golden flowers from Copper pod. Trees and flowers are predominant in the buzzing part of the city.| Posts on Technical Ramblings
August 11th to 15th is a long weekend and I decided to leave Bangalore on August 11th. I booked KSRTC to Coimbatore. The boarding point, St John’s office is few kilometers away from my office in teachers colony. The pickup time was 9:45 PM. I booked Uber pool at 8:35. The first driver handcuffed me to cancel the ride with notorious usual reason - traffic. It took fifteen minutes to find an another car. The driver picked me up at 8:50 and started the vehicle in mushroomed traffic. I sat in t...| Posts on Technical Ramblings
As per Wikipedia , Exception handling is the process of responding to the occurrence, during computation, of exceptions – anomalous or exceptional conditions requiring special processing – often changing the flow of program execution. In Python errors like SyntaxError, ZeroDivisionError are exceptions.Exception paves the way to alter the normal execution path. While working with API, a web request goes through the following process,authentication, authorization, input validation, business...| Posts on Technical Ramblings
A state machine is an abstract machine that can be in one of a finite number of states. The machine is in only one state at a time; the state it is in at any given time is called the current state. While using the database, individual records should be in allowed states. The database or application stores rules for the states. There are many ways to design the database schema to achieve this. The most followed methods are using int or string field, where each value represents a state. Above i...| Posts on Technical Ramblings
Animal Farm’s satire makes the novella interesting to read. Written after Bolshevik revolution and no reason why lot go over gaga. Confining to Bolshevik revolution is tunnel view. The core of the novella resembles with lot of today’s politics and ancient kingdom. For a moment forget about the bolshevik revolution. Rebellion outbursts, the leader comes to power and slowly vanquishes non believers in ideas or voices. Slowly becomes benevolent dictator for life, corrupt and power moves from...| Posts on Technical Ramblings
Today, I read an article about uvloop. I am aware of libuv and its behind nodejs. What caught me was “In fact, it is at least 2x faster than any other Python asynchronous framework.”. So I decided to give it a try with aiohttp. The test program was simple websocket code which receives a text message, doubles the content and echoes back. Here is the complete snippet with uvloop. I ran naive benchmark using thor and results favoured uvloop.| Posts on Technical Ramblings
Admin dashboard is one of the Django’s useful feature. Admin dashboard allows super users to create, read, update, delete database objects. The super users have full control over the data. Staff user can login into admin dashboard but can’t access data. In few cases, staff users needs restricted access . Super user can access all data from various in built and third party apps. Here is a screenshot of Super user admin interface after login.| Posts on Technical Ramblings
Majority of web frameworks promote MVC/MTV software pattern. The way web applications are designed today aren’t same as 5-6 years back. Back then it was server side templates, HTML, API’s weren’t widespread and mobile apps were becoming popular. Rise of mobile and Single Page Application shifted majority of web development towards API centric development. Testing API is super simple with data in and data out, but testing a django view in classic web application is difficult since HTML i...| Posts on Technical Ramblings
Django and Flask are two well known Python web frameworks. There are lot of benchmarks claim Flask is 2xfaster for simple JSON Response, one such is Techempower. After lookinginto the source, it struckme Django can do better! I will compare Flask and Django for simple json response. The machine used is Macbook pro, Intel Core i5-4258U CPU @ 2.40GHz,with 8 GB Memory on OS X 10.10.3. gunicorn==19.3.0 will be used for serving WSGI application.| Posts on Technical Ramblings
Django has very good debug toolbar for debugging SQL. While working with Single Page Application and API exceptions can’t be displayed in browser. Exception is sent to front end. What if the exception can be printed to console ? Django middleware gets called for every request/response. The small helper class looks like Add the filename and class name to MIDDLEWARE_CLASSES in settings file like This is how exceptions looks| Posts on Technical Ramblings
Python set data structure is commonly used for removing duplicate entriesand make lookup faster (O(1)). Any hashable object can be stored in set.For example, list and dict can’t be stored. User defined objects can be stored. Here is how it looks. class Person(object): def __init__(self, name, age): self.name, self.age = name, age In [25]: s = set() In [26]: s.add(Person('kracekumar', 25)) In [27]: s Out[27]: set([<__main__.Person at 0x1033c5e10>]) In [29]: Person('kracekumar', 25) in s Out[...| Posts on Technical Ramblings
Decorator Decorator is a callable which can modify the function, method, class on runtime. Most ofthe decorators uses closure but it is possible to use class. Closure import functools def cache(f): storage = {} @functools.wraps(f) def inner(n): value = storage.get(n) if value: print("Returning value from cache") return value value = f(n) storage[n] = value return value return inner @cache def factorial(n): if n <= 1: return 1 return n * factorial(n - 1) >>>factorial(20) 2432902008176640000 >>...| Posts on Technical Ramblings
Fluent Interface is an implementation of API which improves readability. Example Poem('The Road Not Taken').indent(4).suffix('Robert Frost'). Fluent Interface is similar to method chaining. I was wondering how to implement this in Python.Returning self during method call seemed good idea . class Poem(object): def __init__(self, content): self.content = content def indent(self, spaces=4): self.content = " " * spaces + self.content return self def suffix(self, content): self.content += " - {}"....| Posts on Technical Ramblings
Python’s global keyword allows to modify the variable which is out of current scope. In [13]: bar = 1 In [14]: def foo(): ....: global bar ....: bar = 2 ....: In [15]: bar Out[15]: 1 In [16]: foo() In [17]: bar Out[17]: 2 In the above example, bar was declared before foo function. global bar refers to the bar variablewhich is outside the foo scope. After foo invocation bar value was modified inside foo. The value ismodified globally.| Posts on Technical Ramblings
Some of the python source file starts with -*- coding: utf-8 -*-. This particular linetells python interpreter all the content (byte string) is utf-8 encoded. Lets see how it affects the code. uni1.py: # -*- coding: utf-8 -*- print("welcome") print("animé") output: ➜ code$ python2 uni1.py welcome animé Third line had a accented character and it wasn’t explictly stated as unicode. print function passed successfully.Since first line instructed interpreter all the sequences from here on wi...| Posts on Technical Ramblings
As of writing (12, May 2014) latest version of pip is 1.5.1. pip doesn’tallow installing packages from non PyPI based url.It is possible to upload tar or zip or tar.gz file to PyPI or specifydownload url which points other sites(Example: pyPdf points to http://pybrary.net/pyPdf/pyPdf-1.13.tar.gz).pip considers externally hosted packages as insecure. Agreed. This is one of the reason why I kept using pip 1.4.1. Finally decided to fix this issue.Below is the sample error which pip throws.| Posts on Technical Ramblings
I am big fan of bus travel. Still it is my only mode of transportation. The two reason I love it are wind and sight seeing. Whenever the wind kisses me I forget myself and start thinking about memories. The best part of the wind (Thendral) is it kindles happiness, sad moments, memorable ones, wishes and missing. Thendral has complete effect of changing my mood and mode. I don’t think only thendral has this effect. Trees, plants, flowers and water also produces same effect. Bus journey sows ...| Posts on Technical Ramblings
Over period of time few people have asked me in meetups, online I want to learn python. Suggest me few ways to learn. Everyone who asked me had differentbackground and different intentions. Before answering the question I try to collectmore information about their interest and their previous approaches. Some learnt basicsfrom codecademy, some attended beginners session in Bangpypers meetup. In this postI will cover general questions asked and my suggested approach.| Posts on Technical Ramblings
We are writing a small utility function called is_valid_mime_type. The function takes a mime_typeas an argument and checks if the mime type is one of the allowed types. Code looks like ALLOWED_MIME_TYPE = ('application/json', 'text/plain', 'text/html') def is_valid_mimetype(mime_type): """Returns True or False. :param mime_type string or unicode: HTTP header mime type """ for item in ALLOWED_MIME_TYPE: if mime_type.startswith(item): return True return False Above code can refactored into sing...| Posts on Technical Ramblings
Normally I don’t plan weekends. I code, watch movies. This weekend (8th March) was different though. March 7th, friday evening wasn’t good. I was banging my head at work to get api working. Then came back home. Relaxed for an hour Facebook, Youtube. Then opened emacs and started to play Raja sir’s music. Stared at code, walked along the execution. Figured out the issue. Can’t ask for more. Calm and code. Slept at 3.00 AM.| Posts on Technical Ramblings
Python has sorted function which sorts iterable in ascending or descending order. # Sort descending In [95]: sorted([1, 2, 3, 4], reverse=True) Out[95]: [4, 3, 2, 1] # Sort ascending In [96]: sorted([1, 2, 3, 4], reverse=False) Out[96]: [1, 2, 3, 4] sorted(iterable, reverse=True)[:n] will yield first n largest numbers. There is an alternate way. Python has heapq which implements heap datastructure. heapq has function nlargest and nsmallest which take arguments n number of elements, iterable l...| Posts on Technical Ramblings
Let’s say you want to find how many times each element is present in the list or tuple. Normal approach words = ['a', 'the', 'an', 'a', 'an', 'the'] d = {} for word in words: if word in d: d[word] += 1 else: d[word] = 1 print d {'a': 2, 'the': 2, 'an': 2} Better approach words = ['a', 'the', 'an', 'a', 'an', 'the'] d = {} for word in words: d[word] = d.get(word, 0) + 1 print d {'a': 2, 'the': 2, 'an': 2 Both the approach returned same values. The first one has 6 lines of logic and second ha...| Posts on Technical Ramblings
Two Scoops of Django -1.5 is book by Pydanny and Audrey Roy focusing on writing clean and better Django application. If you are using Django in production this is must read book. Q: I am using django since 0.8 do I need this book ? A: Yes, consider the book as starting point to validate your assumption. Q: I just started using django, should I read this ? A: Yes. I started to use django in production last month. Sometimes I felt I should finish this book before pushing any code further. For e...| Posts on Technical Ramblings
It is very common to update single attribute of a model instance (say update first name in user profile) and save it to db. In [18]: u = User.objects.get(id=1) In [19]: u.first_name = u"kracekumar" In [20]: u.save() Very straight forward approach. How does django send the sql query to database ? In [22]: from django.db import connection In [22]: connection.queries Out[22]: [... {u'sql': u'UPDATE "auth_user" SET "password" = \'pbkdf2_sha256$12000$vsHWOlo1ZhZg$DrC46wq+a2jEtEzxmUEw4vQw8oV/rxEK7z...| Posts on Technical Ramblings
In December I was looking for new job. I came across one and applied. After couple of rounds of interview, co founder informed me we will get back to you, but never happened. This sounds normal but it is not. Interview First round of interview started with online pair programming with one of the co-founder X. After that I went to their office, met product manager, co founder X had discussion for an hour. Then we decided we will meet again. After couple of days solved two more problems. Then a...| Posts on Technical Ramblings
Today (31-12-2013) is my last working day at HasGeek. It was in July 2012, I joinedHasGeek. It was fabulous journey for past 18 months, meeting lot of new people, being part of events, writing lot of code. I was part of large, medium, small conferences like Fifth elephant (2012, 2013), Cartonama (2012), JSFoo(2012, 2013), Droidcon (2012, 2013), Metarefresh (2013), various hacknight and geekup. I will be joning Aplopio Technology Inc, flagship product recruiterbox on 16 January, 2014.| Posts on Technical Ramblings
This is the material which I use for teaching python to beginners. tld;dr: Very minimal explanation more code. Python? Interpreted language Multiparadigm Introduction hasgeek@hasgeek-MacBook:~/codes/python/hacknight$ python Python 2.7.3 (default, Aug 1 2012, 05:14:39) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> >>> print "Let's learn Python" Let's learn Python Numbers >>> 23 + 43 66 >>> 23 - 45 -22 >>> 23 * 45 1035 >>> 23 ** 4 279841 >>> 23...| Posts on Technical Ramblings
This article will focus on deploying flask app starting from scratch like creating separate linux user, installating database, web server. Web server will be nginx, database will be postgres, python 2.7 middleware will be uwsgi, server ubuntu 13.10 x64. Flask app name is fido. Demo is carried out in Digital ocean. Step 1 - Installation Python header root@fido:~# apt-get install -y build-essential python-dev Install uwsgi dependencies root@fido:~# apt-get install -y libxml2-dev libxslt1-dev Ng...| Posts on Technical Ramblings
ipython nbconvert has lot of handy options to convert ipynb to markdown, html etc… But I wanted to upload ipynb to gist.github.com and create a link in nbviewer.ipython.org. Started with curl and soon realized, it is getting messy. So wrote a small python program ipynb2viewer, Source code. Install pip install ipynb2viewer Usage Upload all ipynb files in the given path to gist.github.com and return nbviewer urls. ipynb2viewer all <path> Upload mentioned file to gist.github.com and return nbv...| Posts on Technical Ramblings
In December bangpypers meetup, I gave a talk on Why you should use IPython. Here is the link to nbviewer.| Posts on Technical Ramblings
I was learning docker to use in one of my projects. I kept installing packages, finally created required Ubuntu image. Suddenly thought it would be cool if I can generate Dockerfile like pip freeze > requirements.txt. sudo docker run ubuntu dpkg --get-selections | awk '{print $1}' > base.list && sudo docker run pyextra dpkg --get-selections | awk '{print $1}'> pyextra.list && sort base.list pyextra.list | uniq -u > op.list && python -c "f = open('Dockerfile', 'w');f.wr...| Posts on Technical Ramblings
I hardly use easy_install. Nowadays all the python requirements are installed via pip. IPython is my primary python console. After installing mavericks, I installed IPython and fired IPython console. Following warning message appeared ➜ ~ ipython /Library/Python/2.7/site-packages/IPython/utils/rlineimpl.py:94: RuntimeWarning: ****************************************************************************** libedit detected - readline will not be well behaved, including but not limited to: * cr...| Posts on Technical Ramblings
Everyday as a programmer we solve problems and introduce new problems. Most of the time is spent in reading other people source code, library documentation, replying to developers email. Though communication is what programmers do all the time with computer and humans. Programmers around the globe suggests books like SICP. I have never come across people who suggests books like on writing well for programmers. Though I haven’t read the book myself, the point is why aren’t people recommend...| Posts on Technical Ramblings
On my way back to home from work I was thinking, I should take rest. In my world rest always meant working on some non work codebase, reading a book, watching a movie. But I don’t want to do any of these. Then I thought I would just listen to songs, quickly remembered that will not work out because I will start coding. Finally I started to ask myself, is it possible for any human being to sit idle and take rest. Immediately I gave up. Brain will start thinking about something or other, you ...| Posts on Technical Ramblings
How to check given text is palindrome or not def sanitize(text): for char in [" ", ".", ",", ";", "\n"]: text = text.replace(char, "") return text def palindrome(word): # This approach is o(n), problem can be solved with o(n/2) # I am using this approach for brevity return word == word[::-1] palindrome(sanitize("madam")) # True palindrome(sanitize(u"விகடகவி")) # False Here is the hand made version for Tamil # Assign the variable meal the value 44.50 on line 3! # hex values from ...| Posts on Technical Ramblings
Subtitle Generator Using Whisper| kracekumar.com
speed.python.org tracks Python module performance improvement against several modules across Python versions. In the real world, the module level speed improvements don’t directly translate to application performance improvements. The application is composed of several hundreds of dependencies the performance of one specific module doesn’t improve total application performance. Nonetheless, it can improve performance parts of the API or certain flows. When I first heard the faster CPython...| Technical Ramblings
You can find the source code of tutorial in bazel-101 branch. What will you learn? Introduction to bazel build system How to build and run Java package? How to add maven dependency to bazel build files? How to add protobuf compiler to bazel build? Introduction Bazel is imperative build system that can build packages for Java, C++, Python, Ruby, Go, etc … The two main advantages of bazel, One build tool can build packages for variety of languages and easier for platform teams to build packag...| Technical Ramblings