October 21st, 2008 by rohan

Some vim tips

svn diff the current windows file

Put this in your vimrc:

map zs :!svn diff % > /tmp/vimsvndiff<CR><CR>
  \ :new<CR>:r /tmp/vimsvndiff<CR>
  \ :set ft=diff<CR>

Say you’re editing a checked out file and what to see what changes you’ve done without leaving your VIM session? Just type zs when in normal mode. This will open the diff in a new split window.

Apply tabs to a block of text

I found myself doing this often. Visual selecting some text and then applying a regex to prepend some spaces (or a tab) to each line

Put this in your vimrc:

map <C-i> :s/^/ / :nohlsearch
map <C-p> :s/^ // :nohlsearch

So Control-i will insert 4 spaces for all lines of the selected text. Control-p will remove 4 spaces. Very handy!

June 14th, 2008 by rohan

imsense release 1.0

We released imsense version 1.0 yesterday. Friday the 13th! Auspicious indeed. version 1.0 is available as an ISO image download.

The release info on freshmeat.net is here. We got quite a few downloads already. Must be the automated syndication bots. Hope we get some real users soon!

What is imsense?

Imsense aims to be a complete IM (Instant Messaging) Management Solution for organizations. IM Message Archiving, Firewall, Blocking SPIM and many related features. Visit the imsense website to find more. Registration is free, and you get a demo license which give you 10 users. FREE!

April 17th, 2008 by rohan

Finance::Bank::HDFC and Template::Extract

guitar.png

I released Finance::Bank::HDFC version 0.14 recently. The latest release has the all important get_mini_statement() method implemented. Yes! Check your mini account statement (last 20 transactions) from the command line!

The Template::Extract module from CPAN was extremely helpful here. The account statements were available as JavaScript code in the source HTML file.


	dattxn[l_count] = '10 Apr 2008';
	txndesc[l_count] = "Description blah blah";
	refchqnbr[l_count] = '000003009168';
	datvalue[l_count] = '11 Apr 2008';
	amttxn[l_count] = '0.01';
	balaftertxn[l_count] = '999999.99';
	coddrcr[l_count] = 'D';
	l_count ++;

	dattxn[l_count] = '01 Apr 2008';
	txndesc[l_count] = "A millionaire?";
	refchqnbr[l_count] = '037103902179';
	datvalue[l_count] = '01 Apr 2008';
	amttxn[l_count] = '1000000.00';
	balaftertxn[l_count] = '1000000.00';
	coddrcr[l_count] = 'C';
	l_count ++;

Looks just like a template right? Correct. Enter Template::Extract.

Template::Extract - Use TT2 syntax to extract data from documents

This is the template code I used


# template for extracting mini statements
Readonly my $TEMPLATE_MINI_STATEMENT => <<'EOF';
[% FOREACH record %]
    [% ... %]dattxn[l_count] = '[% date_transaction %]';
    [% ... %]txndesc[l_count] = "[% description %]";
    [% ... %]refchqnbr[l_count] = '[% ref_chq_num %]';
    [% ... %]datvalue[l_count] = '[% date_value %]';
    [% ... %]amttxn[l_count] = '[% amount %]';
    [% ... %]balaftertxn[l_count] = '[% balance %]';
    [% ... %]coddrcr[l_count] = '[% type %]';
[% END %]
EOF

After using the extract() method:

my $template = Template::Extract->new;
my $ref = $template->extract($TEMPLATE_MINI_STATEMENT, $response->content);

This is the resulting arrayref. Use it the way you want.


$ref = [
          {
            'amount' => '0.01',
            'balance' => '999999.99',
            'ref_chq_num' => '000003009168',
            'date_transaction' => '10 Apr 2008',
            'type' => 'D',
            'date_value' => '11 Apr 2008',
            'description' => 'Description blah blah'
          },
          {
            'amount' => '1000000.00',
            'balance' => '1000000.00',
            'ref_chq_num' => '037103902179',
            'date_transaction' => '01 Apr 2008',
            'type' => 'C',
            'date_value' => '01 Apr 2008',
            'description' => 'A millionaire?'
          }
        ];

For example:


foreach my $stmt_ref (@$ref) {
      print  "Amount: " . $stmt_ref->{amount} . "n";
      print  "Balance: " . $stmt_ref->{balance} . "n";
}

February 19th, 2008 by rohan

Google Adwords API Guru

Would like to send out my thanks to the Google Adwords API team for selecting me as an Adwords API Guru, specifically geared towards the Adwords API group on Google Groups.

I guess this is because I maintain the Perl library Google::Adwords which you can find on CPAN.

Time to brush up on my Adwords API knowledge!

February 15th, 2008 by rohan

imsense.net website

We released the imsense.net website to the unsuspecting public yesterday. We are quite confident of version 1.0, but have got loads of marketing to do now.

Thankfully, the website is on the first page of results for a Google search using the following keywords:

February 14th, 2008 by rohan

WWW::RapidShare is a time saver

I uploaded WWW::RapidShare version 0.1 to CPAN today. WWW::RapidShare is a Perl module which you can use to download files from rapidshare.com. Currently, only premium accounts are supported. More features coming soon!

Here’s a simple Perl script to download a file. You need to know the entire URL and of course your Rapidshare account ID and password.

use WWW::RapidShare;

my $rapid = WWW::RapidShare->new();

$rapid->url(’http://rapidshare.com/files/file.zip’);
$rapid->account_id(’xxxxxx’);
$rapid->password(’xxxxxx’);

# Download the file associated with the above URL.
# It will be saved in current directory.
$rapid->download_file();

This should work on both Windows and Linux distros.

I also updated the Finance::Bank::HDFC module to version 0.13, which fixes some dependencies.

January 16th, 2008 by rohan

ROWE

From this link

One of my favorite experiments in this realm, which has gotten a lot of well-deserved attention: Best Buy’s radical experiment in workplace flexibility, the ROWE (Results-Only Work Environment) initiative. Created by two HR dynamos (I know, two words you rarely see in that close proximity), Cali Ressler and Jody Thompson, the program attacks head-on what most “alternative work arrangements” only tip-toe around: the fact that we’re literally laboring under a myth (namely, time put in + physical presence + elbow grease = RESULTS). Our assumptions about how work works, where we work, and when we work are relics of the industrial age. That’s not a new problem. ROWE finally addresses it.

The basic principle: people can do whatever they want, whenever they want, as long as the work gets done. Period. You can come in at 2pm on Tuesday. Leave at 3pm on Friday. Go grocery shopping at 10am on Wednesday. Take a nap or go to the movies anytime. Do your work while following your favorite band around the country. The ROWE “13 Commandments” say it all—here are a few:

–Work isn’t a place you go, it’s something you do.

–Employees have the freedom to work any way they want

–Every meeting is optional

–Nobody talks about how many hours they work

–No judgment about how you spend your time

December 24th, 2007 by rohan

CPAN Perl modules as RPMs v/s PAR

After sweating for three days converting a huge number of Perl CPAN modules into RPMs, I finally decided to go the PAR way. I’m trying to get a nice overview of all the Perl CPAN modules required for most of my web applications. This is currently for my product imsense, which is an IM (Instant Messaging) Proxy, firewall and message archiver, but I need this for my other web based projects too.

The primary modules I require are:

  • Template (The Template Toolkit) - A templating system
  • DBIx::Class - A sexy ORM (Object Relational Mapper) for database abstraction
  • CGI::Application - An even sexier web application framework!
  • Curses::UI - For any console apps
  • Log::Log4perl - For system wide logging
  • POE - A Perl Object Environment for writing network servers and clients (It can do much more)

Imagine my state of my mind when I decided to manually work through each of the above modules, gather all their dependencies and turn them into RPMs using cpan2rpm. No, it was not perverse! My main aim was; and still is, to get to know each CPAN module (with all dependencies) which power up my webapp. I must say it was a good learning experience, but extremely tiring.

I gave up midway through DBIx::Class. I managed to go through all the modules which make up Template Toolkit, Curses::UI, Log::Log4perl and POE. DBIx::Class required loads of modules, and I was exhausted by then.

I had a little knowledge of what PAR was, and how it could help me. I decided to spend a few hours to get to know it better, and those hours were well spent indeed. PAR is a Perl Archive Toolkit, which gives Perl developers the ability to package, maintain and deploy their Perl based applications. It can even package it all into a single executable built for a specific architecture.

This is what I did. First, install PAR::Dist on the target system. This only needs a base installation of perl. PAR::Dist has no other dependencies. On your build machine, use cpan2par from the PAR::Dist::FromCPAN module to create a PAR file from a CPAN module.

I ran it this way:

$ cpan2par -f -p DBIx::Class

and what I got was a PAR file of the DBIx::Class module and all its dependencies as additional PAR files!

Transfer the PAR files to the target system, and use the install_par() method from the PAR::Dist module. Again, the target system is a bare bones Linux system with only a base installation of perl; no other CPAN modules.

A short script which will install all PAR files in the current directory.

#!/usr/bin/perl
use strict; use warnings;

use PAR::Dist;

my @par_files = glob(”*.par”);

for (@par_files) {
    install_par($_);
}

And now the target system is all setup with a working installation of the DBIx::Class module. Handling upgrades should be easy. Just create a new PAR file and deploy it to the target system. PAR supports repositories too, similar to yum, which I definitely need to check out soon.

CPAN can search for data for affiliate marketing. PERL can read through sites for search engine marketing. Many people find advertising flyers to have minimum value. Through internet advertising, millions of users come across 1000’s of web companies daily. Excellent marketing can make you rich. But start with a good web site design that will appeal to millions of users. Advertise your website through a good web hosting company and then you will see yourself getting somewhere.

December 10th, 2007 by rohan

The BLOCK directive in Template Toolkit

The BLOCK directive in Template Toolkit is a cool way of repeating short text, rather than creating a new template file.

You know how we like to separate our menu entries on our website with a |.

<a href=”/features”>FEATURES</a> |
<a href=”/screenshots”>SCREENSHOTS</a> |
<a href=”/contact_us”>CONTACT US</a>

I might need to change that separator into something which looks better. Probably add some more whitespace, change the color, or even use some cool image.

Use the BLOCK directive.

[% BLOCK menu_separator %]
&nbsp;&nbsp;<b>|</b>&nbsp;&nbsp;
[% END %]

What I’ve done is shoveled away my menu separator in the menu_separator BLOCK, which I can then call (execute) by using the PROCESS directive.

<a href=”/features”>FEATURES</a>
[% PROCESS menu_separator %]
<a href=”/screenshots”>SCREENSHOTS</a>
[% PROCESS menu_separator %]
<a href=”/contact_us”>CONTACT US</a>

Cool. Right?

Now to use CSS to jazz it up, because we can, you just need to edit the menu_separator BLOCK.

[% BLOCK menu_separator %]
<span id=”menu_sep”>|</span>
[% END %]

December 7th, 2007 by rohan

imsense release

I’m working hard on one of my products, imsense - An IM (Instant Message) proxy and message archiver. It currently supports MSN and Yahoo IM protocols. I hope to release v1.0 before this year end!

Deployment is going to be my biggest hurdle. I’m checking out rpath, and hope its quick and easy to setup.

Keep visiting. For queries, you can email me at services@aarohan.biz

The 640-822 exams will consist of questions relating to implementing routers and networks. The 350-018 exam is designed to challenge even the most experienced professionals. Students hunting for good resources to prepare for the 156-215 exams, try the smartcenter guide. You will be able to develop your own integrated solution after passing the 642-372 exam for such instant message boxes. Take course 2272 to study for the 70-270 exams. Remember the SY0-101 exam has only multiple choice questions. You will have 90 minutes and 50 questions to complete in the 70-294 exams.

October 31st, 2007 by rohan

PayPal withdrawal to bank account in India

More good news!

PayPal now supports withdrawal of funds into my bank account in India. Excellent! I’m not sure why IDBI bank is not listed though :(

1Y0-259 objective is to prepare you on how to increase and decrease policy priorities. 640-822 is for small branch networks. The 642-453 gatekeeper’s exam is associated with the certificate for ccvp. The 642-642 exam consists of classifying different mechanisms. In order to study for the 646-203, you will need to research all types of networks. To understand basic networking concepts, take the N10-003 course. PMI-001 is the project management professional exam that will help you manage sites like paypal for withdrawals.

October 27th, 2007 by rohan

Scanning on Linux with xsane

Reminder to self

Use xsane for scanning on Linux and not Kooka.

  1. Switch on your printer/scanner.
  2. Load original document into feeder.
  3. Start xsane.
  4. Click on Scan.
  5. Save scanned document as jpg or pdf.

That simple!

p.s. I have nothing against Kooka. I was too lazy to get it to work. xsane worked quicker.

October 4th, 2007 by rohan

New PayPal Withdrawal Feature

Excellent!

I can now transfer funds from my PayPal account directly to my Visa card(s) in India. A 2.4% to 3.4% fee would be applicable, but should be worth it. Compared to the time you have to wait from a cheque to arrive in post, and then the additional three days for it to clear.

Read more here

Network interface cards have nothing to do with a credit card. In fact, a credit card can help you BUY a network interface card. When you work from home, the cash can roll in right from your desktop. By the click of your mouse, your online credit card could be sent to you in a matter of days. But be careful to have some type of debt management before you get into bad credit. Insurance companies invest with cheap loans. And they find it easier to make money if they have good insurance leads.

August 29th, 2007 by rohan

Using folds in vim

Using folds in Vim is a fantastic way to improve your productivity.

Here’s a screen shot showing Vim open with a Perl module without folds.

wo_folds.png

And this is a screen shot with folds enabled.

w_folds.png

Notice how I’ve folded all the subroutines so I get a nice overview of the code.

By heart these commands:

  • zf - Create a fold
  • zo - Open a fold
  • zc - Close a fold
  • zO - Open all folds recursively Yes, folds can be recursive!
  • zC - Close all folds recursively
  • zR - open all folds
  • zM - close all folds
  • zi - Toggle between opening/closing all folds

All folding information is lost once you quit Vim. Use mkview to save your folds information and loadview will reload your folds.

This tip from the vim.org website is extremely handy.

Basically you add this to your $HOME/.vimrc file

autocmd BufWinLeave *.* mkview
autocmd BufWinEnter *.* silent loadview

Happy editing!

August 22nd, 2007 by rohan

svn repository commits

My svn repository is now at revision 1111. Thought it would be good to announce this to the world!

This is over a period of 18 months, which turns out to around 2 commits per day.