Monday, April 22, 2024

Solution for concurrency in multiple JVM instances

 https://stackoverflow.com/questions/51287594/spring-boot-concurrency-issue-for-database-calls

Saturday, May 29, 2021

Short description on Spring JWT authentication

This is the short explanation I've come across how Spring Boot with JWT works on reddit:

You can integrate it with Spring security by adding a filter, which extracts the token from the requests headers, and maybe reject the request if the token is invalid or expired. Then most examples uses the payload of the token to build an authentication object, and then put it in the security context holder so Spring can use it, and you can access it from everywhere (via the security context).

Thursday, March 29, 2018

Table topics side project upfront design

Prior to starting, I wondered why not have some sort of design up-front. This will also help avoid going out of scope and strive to establish a baseline to move forward from.

This webapp will have all the data in sqlite probably. The index page will have some general information. Listed here are some key pages we will incorporate.

Tags page: This will show all the relevant tags out there. Once clicked on the required tag another page with all. A wireframe later on could be hatched out similar to below main page wireframe. This can be left as an exercise for free time.

Main page: Display all with pagination. If there are 100 topics display 10 topics per page. So this is accommodated in 10 pages overall. The index page wireframe is sketched out: https://wireframe.cc/GMUaUB



Optional: Search box leveraging search utility such as Whoosh. There exists extensions for Flask that could fill this gap. This could be displayed in all pages and hence in the parent template.

With the extent of functional aspect out of view, let us focus on the relationship of data when a post belongs to one or more tags. This calls for a many-to-many relationship.


To be continued...


Wednesday, March 28, 2018

Project ideas

This would act as a placeholder and a brain dump ;)

  • Reddit bot to respond when a post has all caps

Quote of the Day


I wanted to work on a side project over the weekend. That would involve creating a website that generates table topics.

This is a small project in Flask framework. What I essentially did was to hit a Quote Generator API. The request library in Python helps do that and even do the germane JSON transformation and response building.

Just wanted to get the ball rolling. Although from cosmetic perspective could throw in some CSS as well but what the heck!

This has me all set in the right direction. Some key things to get right next time:


  • Download bootstrap instead of CDN
  • Create a separate css folder in static
  • Add virtualenv and relevant file formats to .gitignore

Tuesday, March 27, 2018

Triaging tries [Draft]

I was reading through How to Solve it by Computer however, couldn’t find anything on trie. A mechanism to search for and insert strings. Following from other search tree data structures we will build a search tree. I've taken Sedgewick's algorithm book for reference.

Basic properties
Root does not have any character key as well as value in it unlike other nodes that have characters associated with it.

We will describe the technique by which an R-way trie operates. The string for example we have “she sells sea shells by the sea shore”. The last character of the key has a value associated with the node. This is usually the index of the key within the original string. For instance, the key she will have the value as “0” on the last node having the last key character, in this case “e”.

Searching
For searching, we follow all the characters in the key and return the value corresponding to it in order to indicate the search succeeded otherwise a null value at the end indicates that the key does not exist within the trie. With this out of the way let’s see how code would look like:

Insertion
To insert any key we first and foremost search within the trie. If it doesn’t exist we create a new start node and move ahead similarly.

Deletion
Deletion works by traversing to the value of the last key character and if at all found remove that node. And go backwards and delete nodes until you find a node that has a corresponding value.

Other key operations among others
keysWithPrefix – This will return a queue with similar keys that matches the input key

Advantages
Use trie when search should include prefixes otherwise a hash table would suffice.

Friday, March 23, 2018

My experience with Carpooling

In the past couple of months I was sort of compelled to try out carpooling to my office. I've been on both sides of the table(either as a ride giver or a ride taker) and I'd say I've had mix experience. At the end of the day I don't regret doing that.

A friend had introduced me to Quick Ride Android app. The app was reliable at least during the  early stages. It was no hassle getting rides in the morning though it was a challenge while leaving work. Even SRide app connected me to trustworthy carpoolers.

Some days passed by, I was made a part of a WA group and yeah this made me acquainted with some nice folks. However, when giving rides I noticed some idiosyncracies:

  • Fellow riders asking intrusive questions like how much the car costed and grilling why I preferred one brand over another if my mileage is less
  • Questioning how much I make blatantly
  • Whether I stay in a rented or owned house

That too when you are meeting someone for the first time. Another incident that is fresh is one guy was arguing left and right during the whole time. It was the tipping point where I decided upon to only carpool with a select few. 

Overall it was a decent experience with the only caveat avoid carpooling with total strangers.

/ Rant end