Categories
PHP

FeedParser: A PHP Class for Quick Feed Parsing

Well, it doesn’t require any further explanation — we the web developers know how often we need to parse feeds. It’s a very common practice to use SimpleXML for parsing feeds. But today Hasin vai (Hasin Hayder) showed me a very cool thing — the Google Feed Parser. It’s a web based feed parser that is internally used by Google. The coolest thing about the parser is that it returns data as JSON 🙂

Seeing the point, I quickly fired off my netbeans IDE and wrote a php class for quick feed parsing 😀 Why fetch the feed and then parse it? Let Google handle the parsing and fetch the parsed results 🙂 Google is really making our lives simpler!

Here’s the class definition:

So, how do you use it? Initiate a new FeedParser object and then call the parse() method with the feed URL and entry count. The second parameter is optional and is “5” by default.

So what do we get in the $data array? Good question, lets see :

Categories
Javascript

JSDB: A JavaScript Interpreter

Recently I have taken keen interest in JavaScript, mainly because to handle jQuery better. I have always found JS very cool but never had the time to dig deeper into the language. In this EID vacation at KU, I had plenty of leisure times even after my tasks at Leevio and the free lance jobs. I started passing time with JS and found something really cool that I didn’t know so far.

JavaScript is a programming language. Yeah, just like the interpreted languages like Python, PHP and Ruby, JS is another good old programming language. My ignorance, I never knew this! 🙁 I have always thought that JavaScript is merely a client side scripting language that works with web browsers only 😛

My perceptions started changing few months ago when I saw some server side applications of JavaScript coding. Lately, a few days back I saw the node.js projects which is quite similar to the Twisted project implemented in Python. I started wondering how JS is being interpreted on the server side. Google answered me 😀 There are JavaScript interpreters for even shell scripting 🙂

I first tried the interpreters from Mozilla but unfortunately couldn’t make them work on my machine. So, I switched to JSDB 😀 The interpreter is available free for download at: http://www.jsdb.org/ 🙂

They say on their homepage:

JSDB is JavaScript for databases, a scripting language for data-driven, network-centric programming on Windows, Mac, Linux, and SunOS. JSDB works with databases, XML, the web, and email. It is free and open-source. Use it as a JavaScript shell, to run CGI programs, or as a web server.

Yeah, I indeed use it as a JavaScript Shell 😀

Here is the Documentation of what JSDB has inside. I have made a PDF print out of the page for offline reading!

I really find the tool interesting because I am writing small throw away programs those are not really that much useful but the development curve is contributing to my JS skills 😀

Categories
Javascript PHP

jQuery with PHP

I am learning jQuery these days and here’s the source code of a php script that uses jQuery on the client side.

I have mainly demonstrated jQuery here. PHP has been used to manipulate desired number of paragraphs quickly 😀

You get a number of paragraphs. Hovering over them changes their style. Clicking the “Hide” link hides the paragraphs one by one. 🙂