Blog

GP launched 013: Update your RegExp!

Grameenphone quietly rolled out its 013 series of numbers and it wrecked everything. No web service, including Google is working with this 013 series of numbers. Its time for developers to fix this mess and update every validation logic you may have for validating mobile numbers or MSISDNs.

I enlisted a few RegExps for de-terrorizing you, even if a bit.

01[35-9]\d{8}

Enough reading, update your RegExps now!

Flask-like “global” request context in Sanic (asyncio)

Although something like Flask’s globally accessible request object is considered a terrible way of writing code (explicit is better than implicit), sometimes it makes sense to use it. For example, while passing a Correlation-ID to track a request’s life cycle through your micro-services.

Continue reading Flask-like “global” request context in Sanic (asyncio)

Viewing OpenCV matrices with matplotlib (w/ Jupyter Notebook)


Notice: A non well formed numeric value encountered in /home/adhikary/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118

Notice: A non well formed numeric value encountered in /home/adhikary/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119

While working with OpenCV, constantly popping up a new Window to view the results might not be the most effective way of work. However, we can minimize the burden if we are working on Jupyter Notebook; with matplotlib. Essentially we plot the matrices with matplotlib.pyplot.imshow.

Continue reading Viewing OpenCV matrices with matplotlib (w/ Jupyter Notebook)

Reading Bangladeshi NID and Smart Cards with ZXing

Bangladeshi NID and Smart Cards come printed with a 2D Datamatrix Barcode, known as PDF417. The information on the cards can be extracted without using an OCR solution through the barcode. We’ll be using Google’s ZXing library; learn about the basics of using it. Continue reading Reading Bangladeshi NID and Smart Cards with ZXing

Beginners’ Guide to Effortless Doctests in Python


Notice: A non well formed numeric value encountered in /home/adhikary/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118

Notice: A non well formed numeric value encountered in /home/adhikary/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119

Doctests are essentially tests embedded in a docstring. They serve both as example use cases and test cases! A Python expression is provided along with an expected outcome, a test runner collects that and evaluates the expression. Continue reading Beginners’ Guide to Effortless Doctests in Python

Simple Python Profiling with IPython

Profiling is imperative to understand your application. However, getting started with profiling might seem to be a steep learning curve; but it doesn’t have to be! IPython has a lot of built-in magic commands, and some of them are helpful to profile your Python code. %timeit and %prun are among the ones I found most useful. Continue reading Simple Python Profiling with IPython

Mitigating High-Traffic with Simple Static Content Generation

Your application probably does not need to execute some code each time it is used. We have been caching for decades; reducing database queries, using key-value stores, OPcode caching and the list runs on. Things become overwhelming. I believe often we can find the best answers in simplicity; complexity should not be introduced where a simple solution can help. Continue reading Mitigating High-Traffic with Simple Static Content Generation