I am a 20yr old b.tech final year computer science student, a Geek, Photography freak, Web Designer, Developer, PHP Ninja & Tech addict. I love Juggling, Art, Doodling, Music, Poetry & Cooking . This is my online space, which would showcase my works. I would love to have feedback and feel free to say hi
I currently am an intern developer at ESPN Cricinfo.com, before which freelanced for 3 yrs while at college!
March 8th, 2010 | In PHP, Programming, Projects | No Comments »
Flipkurl is a php-curl based api library to access the contents of flipkart.com site, login into it, search book listings, add books to cart, move books from to wishlist, read contents of cart, etc.
Usually shopping carts don’t persist the user’s selection across logins, but this one does. So whatever books you add via the library will stay in your account, so you can checkout/pay later from there.
Some possible uses of the API include Custom User Interfaces, Mobile UI’s, Mashups with other API’s, Automate stuff, etc.
The library is released under GPL. You can find the code, more details regarding the library and examples here – http://code.google.com/p/flipkurl
It was done as a fun weekend project.
Tags : api, flipkart, library, opensource, weekend project
March 1st, 2010 | In PHP, Programming | No Comments »
Curl is a very interesting utility library which lets one connect and interact with any remote url via any of the supported standard protocol. Though curl is essentially a command line tool, various bindings are available for access via programming languages, popularly php
From a php perspective, curl can be used to remotely access any URL, login, authenticate, and perform other actions. Directly using curl to retrieve content is a no brainer like fetching rss feeds, etc.
<?php
$ch = curl_init( "http://www.foo.com/test.php");
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
$content = curl_exec( $ch );
?>
Going beyond that a common scenario can be a contacts grabber, in which the user specifies the auth details, the script logins into email servers, fetch the contacts in a usable format. More interesting applications can be interacting with payment gateways, shopping carts, etc.
This weekend has been spent with curl after long time, extracting data and fooling around with it, it just too much fun !
There are lots of examples and documentation regarding handling of cookies with php curl. But there are couple of catches which always turned into dead ends for me in the past couple of years, and i never really bothered to find way around as i didn’t needed them in the past. The curl documentation suggests you set the cookie handlers for curl this way, and usually as with any other php function relative paths should work, like this…
<?php
curl_setopt( $ch, CURLOPT_COOKIEFILE, "file.txt" );
curl_setopt( $ch, CURLOPT_COOKIEJAR, "file.txt" );
?>
But weirdly for some reason relative path doesn’t work ! Since my weekend fooling with curl needed it, on playing around with it a little and discovered that giving absolute path works, it just works. So using the realpath() makes it all easy.
<?php
//$fileName = "/home/kalyan/curlfoo/file.txt";
//or just use the real path function
$fileName = realpath( "file.txt" );
curl_setopt( $ch, CURLOPT_COOKIEFILE, $fileName );
curl_setopt( $ch, CURLOPT_COOKIEJAR, $fileName );
?>
Tags : cookies, curl, PHP, weekend project
February 20th, 2010 | In Photography | No Comments »
I am sitting here,
with mind somewhere
wondering what in life,
am i looking at ?
though my other senses are
functional and intact
but with broken sight,
what am i looking at ?
| Camera: | DSLR-A200 |
| Exposure: | 1/4 |
| Aperture: | f/5.6 |
| Focal Length: | 70 mm |
| Exposure Bias: | 0 EV |
| ISO Speed: | 400 |
| Flash: | Off, Did not fire |
Tags : black and white, broken, broken sight, eyeglasses, Photography, poem, thoughts
February 15th, 2010 | In Photography | No Comments »
My desk …
Shot in black n white ! Edited in Gimp !
Tags : black and white, book, chaos, desk, gimp, notebook, Photography
February 10th, 2010 | In Photography | 1 Comment »
The Fallen beauty someday shall wake up,
For she has the seeds to her offspring’s,
to multiply and make it up,
But alas, she shall die on the road,
before they get planted up.
Tags : flower, orange, photograhy, road
February 9th, 2010 | In Programming, Python | No Comments »
If you haven’t seen this before, the first thing that probably would occur is either the programmer has missed a == or has just gone mad, but apparently in python its valid. Python booleans True, False can actually be assigned values, and they can also be inter assigned.
>>> False
False
>>> True
True
>>> False = True
>>> False
True
>>> False == True
True
The reason for this being True & False are not real ( can’t use the word True, can’ i ? ) keywords but mere object instances of type Boolean. Since variables in python are untyped, its technically possible to assign any python object. Makes sense.
>>> False = 10
>>> False
10
>>> type(False)
<type 'int'>
>>> True = "what is this?"
>>> True
'what is this?'
‘None’ type since it being a real keyword(since 2.3), throws SyntaxError.
The good thing taken care to avoid confusion is logical statements will always return a new instances with a boolean value of 0 or 1 represented as False & True.
>>> False = True
>>> False
True
>>> True = 10
>>> True
10
>>> True = (1==1)
>>> True
True
>>> False = not True
>>> False
False
Apparently some say this is a feature of python, but i can only imagine the havoc single such statement can cause.
While the explanation for True,False is plausible, python weirdly lets you switch data types of data types, which just doesn’t make any sense.
>>> int
<type 'int'>
>>> str
<type 'str'> #makes sense
>>> int = str #but wth?
>>> int
<type 'str'>
It makes me wonder why would anyone ever in the insanest of their minds let you do that in an otherwise beautiful, sensible, sane & poetic language. Okay, poetic maybe an overstatement, but it does look beautiful, doesn’t it?
Tags : Programming, Python, types, variables
February 8th, 2010 | In Photography | No Comments »
Self descriptive and thought reflective.
Its always the un-answerable question solution the question of how far have we come to full-fill the purpose of our life, a question which lurks in every sane mind trying to understand why things are the way they are, a question which drives us nostalgic, to drive insane at the sanest of times.
So where has it come to for you ?
This photo starring me was shot by me, timed, tripoded and processed in Photoshop.
Tags : black and white, depth, emotion, life