Skip to main content

RegEx : Non-greedy operation without non-greedy operators

In the world of RegEx (Regular Expressions), not all engines support non-greedy or lazy matching capability of input; the lazy matching was introduced in Perl, so any Regex engine that implements PCRE (Perl Compatible Regular Expression) supports lazy matching out of the box.

If you're on an engine that does not support non-greedy match, you can use some trick to achieve that.

Read more…

Primer on Bash variables, logical builtins/commands, and operators

bash is written in C, so one might expect some remnants of C, but the fact is bash is very different from it -- bash (or any other shell, for that matter) was never designed to be a full-fledged programming language. bash was initially written to execute various *nix standard commands directly, in essence, an interface to do fork()-exec() (and brothers) calls.

Read more…

Python : Turning a sequence into an iterator without iter(), keeping the sequences' properties intact

From time to time, we have come across questions like -- How can I make an iterator out of a sequence without explicitly calling the iter() function?

A follow-up question to that would be -- Can we preserve the sequences' properties intact, with just adding the needed properties to make it an iterator?

In answering these, we are also answering the obviously inferred question -- How can I expand functionalities of a class without modifying the class itself?

Read more…

Abstracting the inits -- run "service action" commands with ease!

On GNU/Linux, from time to time, we tend to face the issue with mistakenly using wrong service action commands on various init systems. For example, on a system with upstart being the init, one can mistakenly run

systemctl restart sshd

whoops! this is not a major mistake by itself but could easily turn into one (damn you muscle memory!)

Read more…

Hello, World!

The title is a must, isn't it? :)

Hello there, Not sure when you are reading this, but glad you are here! -- reading the first post on my blog.

Read more…