I Hate Regex

Every time I have to use regex, I must look up the Interne for the regex pattern syntax, try some variations with my code, and eventually falling back to some regex website to find pre-made patterns for my specific case. I know I’m not alone in this. I have at least half-a-dozen regex websites in my bookmarks. We know that new one of these pops up so very often, while the old ones vanish in the archives of the internet.

Here are some wise words from the Internet about this regex situation:

So here we have another contender with a difference: don’t just use; understand.

Yes, iHateRegex.io, and so does many, but this website is working against it. While you are here looking for your specific case of regret… I mean regex, the website helps you understand how the regex pattern is working to find the match from the given input by showing a visual explanation of the process. Pretty neat eh!

Image courtesy: iHateRegex.io’s GitHub repo

Found some useful examples here and I think they are doing a good service to the developer community. Bravo guys!

Website: https://ihateregex.io/

GitHub Repo: https://github.com/geongeorge/i-hate-regex

Go, give it a try.


A Simple Log Helper for Python

Just wanted to share this simple log helper method I came up with after some research, which can help you quickly setup Python logging and focus on your main app logic instead of dangling around in logging documentation.

The method is very simple, takes a filename and two other optional arguments, and returns ‘logging’ object, and you can start logging in your Python projects in no time!

Here’s the code:

#file log_helper.py
import os, sys
import logging

def logHelper(fileName, logLevel=logging.INFO, useConsole=True):
    Simple Logging Helper. Retuens logger reference.

    fileName: Filename, may include full path, or will open a file in default folder
    logLevel: Pass logging.INFO, logging.DEBUG or other enums for logging level
    useConsole: If Ture, will also dump log to console

    ##### init logging
    log = logging.getLogger()
    logFormatter = logging.Formatter("%(asctime)s | %(threadName)-12.12s | %(levelname)-5.5s | %(message)s")

    ##### file handler
    fileOut = logging.FileHandler(fileName)

    ##### console handler
    if useConsole:
        consoleOut = logging.StreamHandler(sys.stdout)

    ##### return reference
    return log

And usage is simple. Passing just filename defaults to ‘logging.INFO’ log level, and console output turned on:

#import module
import log_helper as log

# get logger
log = log.logHelper('logfile.log')
log.info("Got logger")

Or use optional arguments to set up logging level and console output:

#import module
import log_helper as log

# get logger
log = log.logHelper('logfile.log', logging.WARN, False)
log.warn("this is a warning message")

Additionally, you can always tweak the method as per your needs, for rotating file handler, additional output handlers and log output format.

Check out Python’s documentation for ‘logging’ module here for more info.

Bugs reports? Suggestions? Let me know if you found this useful. Leave a comment 🙂


// Sohail

Deploying Network Services behind Corporate Firewalls: Net.TCP Port Sharing in WCF

Just found a good feature of WCF, which seems quiet useful for distributed application developing/deployment practices. Through Net.TCP Port Sharing Service, Windows Communication Foundation (WCF) allows different processes to share the same TCP Ports. Now you can deploy your .Net based network services side-by-side with IIS on port 80 or 8080, the standard HTTP and HTTP Proxy ports you find open in many firewalls by default. No need to mess around with client

uTorrent for Mobile

Wait a minute… you think you can leech some bits of torrents from every public hotspot that comes your way? No sir, that’s not the case (at least for now). This neat piece of software is not a torrent client, it actually lets you control the uTorrent from your mobile, ideally on Wi-Fi in home or office, where you have uTorrent running with WebUI installed.

I just happen to setup WebUI for myself and had this wild idea to get the remote control on my mobile, and guess what, “Your best idea is already copyrighted.” proves true again!

These guys here have done a great job actually. The uTorrent Remote Control is done in J2ME, with a simple interface, lets you control and monitor torrent activity on your uTorrent application.

I also found some other useful bits here on the same site, but I’m in love with this torrent thingy I tell you that. Go try it for yourself!


// ch3ckmat3

More e-paper, more e-book readers

The scene has now become interesting with a number of e-paper based portable e-book readers on the market, and we are getting a brand new gadget every once in a while in this pool now.

Just like BeBook, yet another cool e-book reader on the block…but still no luck with the prices…the asking price for this gizmo is huge 329.95 EUR with converts to almost 510 USD!!!

The success of Sony Reader and Amazon Kindle Reader proves that even latest large screen mobile phones and other hand-held media gadgets are insufficient for reading books, specifically for mature readers.

For other options available, here is a good Feature Matrix on E-book Readers I found on MobileRead Wiki.


// ch3ckmat3

Eid Mubarik & my brand new blog theme :)

Eid Mubarik to all Muslims around the world 🙂 Eid-ul-Fitr is truly a family event and my best wishes to those who are abroad and for any reason, couldn’t make it home with their families. 

Me and Faisal has also upgraded our blogs to WP2.3 with brand new themes from N.Design Studio… And these are really cool Web 2.0 designs. Thank you Nick La for great themes. Your work is really cool.

Enjoy your Eid Moments and Happy surfing!

// ch3ckmat3