The Storyteller

Installing Storytlr in your own domain

January 25, 2010 · 3 Comments

When lifestreaming services come under the spotlight, Storytlr is definitely a promising one. They started their journey not more than a year ago, was loved by many other people out there, and decided to shutdown! Ok, that makes sense when the economy was so scary lately, but the good thing is that – they didn’t just announced “We are shutdown, and we don’t care what the fuck had you built with us”. Those brilliant people behind Storytlr did something very much appreciable, they made their brain child open source. I really loved that. The source code is available to download from their google code project page.

Other than Storytlr, there is another open source life streaming service available at this moment which is “pubwich” and is available to download from http://pubwich.org

My post is about how you can grab the source code of Storytlr and set it up in your own webserver. I’ve seen many people were asking on the mailing list an their news blog about how to install this one successfully. So I decided to give it a shot and install it. Follow these steps and you are good to go :)

#1 Add a wildcard A record pointing to your server’s IP
#2 If you are hosted in VPS, and you have multiple domains hosted, you may want to create a Virtual Host with the following entries. I just assumed that your document root for Storytlr will be at “/var/www/storytlr”

<VirtualHost *:80>
        ServerName domain.tld
        ServerAlias domain.tld
        ServerAdmin admin@domain.tld
        DocumentRoot /var/www/storytlr
       	<Directory /var/www/storytlr>
                Options FollowSymLinks
                AllowOverride All
        </Directory>
</VirtualHost>

Dont forget to restart/reload your web server after this.

#3 change your current workign directory to /var/www/storytlr and download the latest available storytlr from google code, and then extract it :)

wget http://storytlr.googlecode.com/files/storytlr-0.9.2.tgz
tar -zxvf storytlr-0.9.2.tgz

Now you will see some directories in the same path.

#4 Create a mysql database named “storytlr” (You can name it whatever, just dont forget to change the DB settings accordingly in the config. I will be discussing this later) – also create a user for this db and grant it all permission for this db.

mysql> create database storytlr;
mysql> grant all on storytlr.* to 'storytlr'@'localhost' identified by 'password';
mysql> flush privileges;

#5 Now you need to import storytlr’s schema into it. change your working directory to /var/www/storytlr/protected/install and import the database.sql into the recently created “storytlr” db

mysql -u storytlr -p storytlr < database.sql

#6 You need to install a PECL extension “tidy” to make Storytlr work properly. So if you dont have that installed on your server, you can do this using the following command

apt-get install php5-tidy
or
pecl install tidy

if you install it via “pecl” then dont forget to add this line “extension=tidy.so” in your php.ini. Also in this case, make sure that put tidy.so inside the directory which is mentioned in the php.ini as “extension_dir”

restart your webserver

/etc/init.d/apache2 restart

#7 Now you need to add write permission to some directories that storytlr needs. Change your workign directory to /var/www/storytlr/protected and apply the following commands

chmod 0755 logs
chmod 0755 feeds
chmod 0755 temp
chmod 0755 upload

#8 We are almost done. Now change your working directory to /var/www/storytlr/protected/config and copy the config.ini.sample as config.ini. Edit this config.ini – you need to make various changes here.

#line number 1: if you have PDO and PDO_MYSQL installed in your machine, leave it as is – or else change it to “MYSQL” instead of “PDO_MYSQL”

Change DB settings. Add appropritae uername, db name and password there

Change line number 14, 15, 16 and remove the comments (the semicolon ;) from in front of them. Its better to add caching.

Change line number 19 and add your host name. You may also change the timezone to your working one.

Change line # 25, set app.closed = 0. You want to enable registration for your visitors, right?

Comment out line number 28 (app.user = admin) and add a semicolon in front of it :)

Change line #39 (flickr.api_key=) – add your Flickr API key there. This is optional :)

You may also change line number 57 and add a google map api key for your domain. This is also optional ;)

#9 Last step, create /tmp/cache directory and add write permission to it :)

Done and Enjoy!

→ 3 CommentsCategories: OpenSource · PHP · pecl
Tagged: , ,

Lookback 2009 and wishlist for 2010

December 26, 2009 · 26 Comments

2009 was a very nice year for me and my family. As of 2007 and 2008, here are some interesting facts of 2009. I just wonder how fast the days pass. :)

1. PHPExperts Workshop in May – It was a tremendously successful event we’ve arranged from PHPExperts with the help of computer club of Brac university.

2. I was one of the key speakers in Facebook Developers Garage in Dhaka. That was also a superb event in overall.

3. I bought my first car, Nissan Sunny 1.5 ltr 2004 JDM model.

4. Bought an iPod classic 120 GB and an iPod touch. Now I had quite a bad luck with both of these :( – my iPod classic HDD was crashed in 5 months and I’ve returned it as a “Sales Return”. Later, my iPod touch home button got stuck and became stiff. I’m still using it.

5. We have a new member in our family, my son Evan in September.

6. I have started a small startup and we named it Leevio. We are currently developing some groupware tools which we hope to release in january 2010.

7. Needless to say, I became 30 years old :D

Wishlist for 2010
1. I wish to have one of the new macbook/macbook-pro sometime in 2010
2. A new car (MT this time, of course). I will mod it myself :)
3. Some cool products from Leevio.
4. A superb WP Theme studio.
5. A new book on Facebook Connect that I am currently working on.

and of course, peace and happiness for everyone. :) May Allah bless you all.

Have a nice year 2010.

→ 26 CommentsCategories: Me - Myself

What is your most favorite Book on PHP?

November 16, 2009 · 34 Comments

My first PHP book was “Beginning PHP4” which I read in 2002. I still remember that dark red cover with smiling faces on top of it :) . It was a good book. I should rather say it was a very good one for kick-starting PHP that time.

So far I’ve read a lot of books written on PHP. But when someone asks me which one is my favorite, I get three or may be four which were very good. First one was Professional PHP Programming. Then comes PHP5 Power Programming. Next comes Advanced PHP Programming and Finally I must say about Zend Enterprise PHP Patterns. Of course there are other books which are very good in fact. But these are my favorite (Well, you see that Beginning PHP4 and Professional PHP4 are obsolete by now, but they helped me a lot that time)

If I have to choose my most favorite one – I would vote for Advanced PHP programming

What is your most favorite Book on PHP? It doesn’t matter if they are obsolete or 10 years old :) – Just share you most favorite one with us :)

→ 34 CommentsCategories: Books & Magazines · PHP
Tagged:

zembly is deadpooled – 2.5 yrs of effort went in vain :(

November 10, 2009 · 16 Comments

Zembly
I got a bad news this morning that zembly is shutting down their service from 30th next. that’s a very bad news because zembly was a nice service for developers. They’d started their business from june 2007, provided exciting APIs to developers to develop mashups on top of popular services like Facebook, MySpace, Flickr and so forth. I’ve seen another popular service like this , appJet, went down this year. Now it’s extremely frustrating that such types of services are shutting down. Why? most probably they’ve failed to secure funding, or may be they’ve some fight in their board of directors, or whatever, who knows and who cares.

But the point is, what happen to developers who has developed their app using services like zembly or appJet? all their efforts to learn these new technology, new tools and to develop some really cool applications using these services just became useless all at a sudden. That’s pathetic, and thats an utter lack-of-respect to your own developers community. These developers are your everything. They were your everything. If these developers didn’t put their efforts for you zembly, you will never survive a quarter, may be six months.

I really dont understand, If you dont have the guts to run your product thats fine. I have no problem with that. But before saying “All our service will be unavailable from blah blah blah” and “We are sorry and blah blah blah” , come on – show a minimal respect to your developer community. After 2.5 years of run, its not a small community after all. And grow up kiddo, before shutting down your company, at least make your project open source – as a sign of minimal respect and loyalty to the developers community who kept you running for so long.

I am sorry for Zembly But I am more sorry for the developer community.

→ 16 CommentsCategories: Cool Webapps · PHP · Web Service · deadpool
Tagged: , , ,

Getting HP-1020 Laserjet Printer working on Snow Leopard

November 5, 2009 · 35 Comments

Since upgrading to snow leopard from leopard, this was the biggest problem and most frustrating thing for me. My HP Laser-jet 1020 stopped working. I’ve downloaded all possible updates from apple and none works. My good old printer just became a piece of brick (lol, yeah really)

So how did I finally get it running? almost 10-20 hours of googling+downloading+trial and error+cursing and drinking a lot of coffee, open source stuffs saved my day :) – here you go .

#1 – download foomatic-RIP from here http://www.linuxfoundation.org/collaborate/workgroups/openprinting/macosx/foomatic (choose the snow leopard package)
#2 – download ghostscript from http://www.linuxfoundation.org/collaborate/workgroups/openprinting/macosx/foomatic )choose snow leopard package)
#3 – download foo2zjs from here http://mac.softpedia.com/progDownload/foo2zjs-Download-33222.html

#4 Ok, now install GhostScript First, then Install Foomatic-RIP. Just perform a default install. no extra thingy – nothing :)

#5 Now install foo2zjs package. while installing, it will ask for admin access. Then it will open a shell window and display you a list of firmware to choose from. You will find HP-1020 listed on #7 – so type “7″ and hit enter. Now if it asks you whether you want to delete the installation file, choose “yes”.

#6 Now open the “helper” folder inside this foo2zjs package and copy the load_LaserJet_firmware_v4 file to anywhere else. We need this file later.

#7 Connect HP-1020 in USb port and Add the printer from your printer preference panel.

#8 Now double click on load_LaserJet_firmware_v4 file that you have copied earlier and run it :)

Ok, now you have a working HP-1020 in your snow leopard. Until HP or Apple releases a patch, this is the only way to get it working. Well, dont forget to send me a cup of coffee for saving you from buying a new printer – lol!

→ 35 CommentsCategories: howto
Tagged: , , , , ,

Using new PECL Memcached extension for storing session data

October 18, 2009 · 20 Comments

Many of you already know that managing session is a critical task for web applications, specially when you want to avoid I/O hop and also a significant load over your database by writing a custom session handler. Beside that, if your application makes use of multiple web servers behind a proxy, then its more than a critical job to share and manage session data among these servers effectively. This is why a central session manager is very important for your application to scale. In this article I am going to show you how you can use the latest Memcached extension (developed by Andrei Zmievski and his team) to isolate the session storage from web servers. I will show you how to compile the extension and use it.

Step1: Install Memcached Server
If you are using Debian its just plain simple

apt-get install memcached

Step 2: Run memcached instances
Lets run two instances of memcached in same machine (well, this article is just for demonstrating you how you can get things done. In the production environment, you can deploy as many memcached instances as you want in different servers in same network)

memcached -d -l 127.0.0.1 -p 11211 -u <username> -m 16
memcached -d -l 127.0.0.1 -p 11212 -u <username> -m 16

Above commands will run two instances of memcached listening on port number 11211 and 11212, same IP 127.0.0.1. Each of them get an allocation of 16 MB of memory (on RAM).

Step 3: Install the PECL Memcached extension.
Lets install the new PECL memcached extension in your web server. This new extension depends on libmemcached. You can grab the latest distribution of libmemcached from https://launchpad.net/libmemcached and compile it in your own machine. Make sure you have the dependencies met.

wget http://launchpad.net/libmemcached/1.0/0.34/+download/libmemcached-0.34.tar.gz
tar -zxvf libmemcached-0.34.tar.gz
cd libmemcached-0.34
./configure
make && make install

Considering everything went fine, lets install the PECL memcached extension

pecl install memcached

If everything goes fine, you should see the output similar like this

Build process completed successfully
Installing '/usr/lib/php5/20060613/memcached.so'
install ok: channel://pecl.php.net/memcached-1.0.0
configuration option "php_ini" is not set to php.ini location
You should add "extension=memcached.so" to php.ini

Make sure that memcached.so is placed in your PHP extension_dir folder (here /usr/lib/php5/20060613). Add the line “extension=memcached.so” in your php.ini and restart your web server.

To make sure, everything’s done and working – run a phpinfo() and check the output. There should be a “memcached” sesction which will look like the following one.

Memcached PECL Extension

Memcached PECL Extension

Now we need to make change in our php.ini to register Memcached as a session handler and set the necessary properties there. Open your php.ini and add the following two lines. If you find any similar line un-commented, comment them out first.

session.save_handler=memcached
session.save_path="127.0.0.1:11211, 127.0.0.1:11212"

Restart your web server. And …… you are done! :) – Now all your session data will be saved and served from these memcached servers. No matter whenever you need to extend your setup by adding extra web servers, all user data and session data will remain valid and served from a central location. No I/O issue, no huge write load on DB servers.

→ 20 CommentsCategories: Apache · OpenSource · PHP · howto · idea · memcached · pecl · performance
Tagged: , , , , ,

RackSpace Cloud Server Client Library for PHP

October 12, 2009 · 11 Comments

We, the developers at Leevio are currently developing an open source group collaboration application. We are using RackSpace Cloud servers since the very beginning of the development and we will also deploy in on rack space cloud.

As a part of our study we’d found that RackSpace provides excellent API to manage your cloud services. Unfortunately there are no language binding library released yet (for Cloud Server). But they’ve mentioned that they are developing one for python.

So we have spend our time for last two days and developed a PHP client library to use RackSpace cloud server API from inside a PHP application.

This client library is released under New BSD license. And is available to download/svn-checkout from it’s project page at http://code.google.com/p/phprackcloud/

There is plenty of documentation and example included. The code is mostly self explanatory. Please dont forget to check the Wiki page to get some idea on how to use this library and how far you can go. We have covered all available methods by RackSpace cloud server in our client library.

Happy clouding.

Project Page and Download: http://code.google.com/p/phprackcloud

→ 11 CommentsCategories: CURL · Cloud Computing · Interesting Links · PHP · RESTFul · Web Service · howto
Tagged: , , , , , , ,

Using iPaper API to convert office documents to flash movie on the fly :)

October 7, 2009 · 12 Comments

Embedding documents in web applications is a challenging work. Because you need to convert these documents into flash movie and only then you can embed them in your web applications. There are many converters available out their for use. Some of them are proprietary, Some of them comes for free. There are command line tools as well as web services also to perform these conversions and make your life easier. In this post I am going to introduce you to IPaper, an excellent service from Scribd. Using IPaper API you can upload and convert your documents to flash movie on the fly, and then you can embed them using Scribd’s excellent document viewer. Scribd offers a collection of client libraries and fortunately, we have a PHP lib in that collection.

Scribd API can convert numbers of document types including the followings

* Adobe PDF (.pdf)
* Adobe PostScript (.ps)
* Microsoft Word (.doc, .docx)
* Microsoft PowerPoint (.ppt, .pps, .pptx)
* Microsoft Excel (.xls, xlsx)
* OpenOffice Text Document (.odt, .sxw)
* OpenOffice Presentation Document (.odp, .sxi)
* OpenOffice Spreadsheet (.ods, .sxc)
* All OpenDocument formats
* Plain text (.txt)
* Rich text format (.rtf)

To use IPaper API, you need to create a developer account in ScribD and get your API key and secret key. Also, download the PHP client library from http://www.scribd.com/developers/libraries

You are ready to go once you get your Scribd api key and secret key. You can upload different types of files to scribd server and of course you can make them private or publicly accessible. After successful upload and conversion you will receive a doc_id and access_key from Scribd web service. Using those data you can embed your document in your web app. Lets have a look. In the following code examples, you may find the getEmbedUrl() and getEmbedCode() functions handy. You can also use SWFObject for quick embedding :)

<?php
include_once("scribd.php");

$UpdloadData = createIPaper("gpl.pdf","pdf","public");
$EmbedUrl = getEmbedUrl($UpdloadData);
echo $EmbedUrl;
$EmbedCode = getEmbedCode($UpdloadData);
echo $EmbedCode;

function createIPaper($File, $FileType, $Access="private")
{
    $scribd_api_key = "<your API key>";
    $scribd_secret = "<your Secret key>";

    if (empty($FileType))
    throw new Exception("Filetype cannot be empty");
    $Scribd = new Scribd($scribd_api_key,$scribd_secret);

    $UploadData = $Scribd->upload($File,$FileType,$Access,1);
    return $UploadData;
}

function getEmbedUrl($UploadData)
{
    if($UploadData){
        $EmbedUrl = "http://d1.scribdassets.com/ScribdViewer.swf?document_id={$UploadData['doc_id']}&access_key={$UploadData['access_key']}&page=1&version=1&viewMode=list";
        return $EmbedUrl;
    }
}

function getEmbedCode($UploadData, $Width=450, $Height=500)
{
    $EmbedCode = <<<EOD
<object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"
    id="doc_512761847372423" name="doc_512761847372423"
    classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
    align="middle"
    height="{$Height}"
    width="{$Width}" >
<param name="movie" value="http://d1.scribdassets.com/ScribdViewer.swf?document_id={$UploadData['doc_id']}&access_key={$UploadData['access_key']}&page=1&version=1&viewMode=list">
<param name="quality" value="high">
<param name="play" value="true">
<param name="loop" value="true">
<param name="scale" value="showall">
<param name="wmode" value="opaque">
<param name="devicefont" value="false">
<param name="bgcolor" value="#ffffff">
<param name="menu" value="true">
<param name="allowFullScreen" value="true">
<param name="allowScriptAccess" value="always">
<param name="salign" value="">
<param name="mode" value="list">
<embed src="http://d1.scribdassets.com/ScribdViewer.swf?document_id={$UploadData['doc_id']}&access_key={$UploadData['access_key']}&page=1&version=1&viewMode=list"
    quality="high"
    pluginspage="http://www.macromedia.com/go/getflashplayer"
    play="true"
    loop="true"
    scale="showall"
    wmode="opaque"
    devicefont="false"
    bgcolor="#ffffff"
    name="doc_512761847372423_object"
    menu="true"
    allowfullscreen="true"
    allowscriptaccess="always"
    salign=""
    type="application/x-shockwave-flash"
    align="middle"
    mode="list"
    height="{$Height}"
    width="{$Width}">
</embed>
</object>
EOD;
    return $EmbedCode;
}
?>

and here is how it will look after embedding

download the source code from here http://www.box.net/shared/5dav7hnkm9

By the way, IPaper PHP client library has some cool methods like uploadFromUrl() – Check them out )

Stay in touch, In next post I will show you how to use some other exciting tools which you can use and host in your own server :) . that will be fun to host your own service like this :)

Thanks to Rana for helping me out with iPaper.

→ 12 CommentsCategories: Cool Webapps · Interesting Links · PHP · Tricks · howto
Tagged: , , , , ,

jQuery:hooking form submit and making it ajax request

October 1, 2009 · 1 Comment

modern javascript frameworks are big blessings to every front end developer. they made our life so much easier so that we can sleep more and become fat day by day :D – i am a big fan of jQuery and mootools.

in this post i am going to show you how you can hook a normal form submission process, regardless of it’s method GET or POST, and convert it into an ajax request. the whole process will work dynamically. it will parse form input elements, make a JSON array from them and make an ajax request to the appropriate action url. after that, it will invoke the user supplied callback function.

problem 1: parsing form elements was a small challenge. you can do it in various way (by traversing or serialize or using css selectors). i choose to use serializer routines. jQuery has builtin support for two types of serializing , one is $(form).serialize() and another is $(form).serializeArray(). lets have a look at the output of both of them for the following form

<form id="f1" action='some target' method='POST'>
<input type ="textbox" id='username' name ='username' value='me'/>
<input type ="checkbox" value=1 id='guests' name ='guests'/>
</form>

now lets check the output by both serialize() and serializeArray() method

alert ($('#f1').serialize());
//output is "username=me&guests=1"

alert($('#f1').serializeArray()
//output is [{object},{object}]

are you scared seeing this [object] output of serializeArray()? well dont panic. serializeArray() returns a JSON structure. you can still investigate using toSource() method

alert($('#f1').serializeArray().toSource()
//output is [{"username":"me"},{"guests":"1"}]

but that will not be usable to send in our AJAX request. we need a JSON array key/value pair (or you can use the output of serialize() function too to send as data in ajax request, the serilizeForm part is completely optional )

lets create a new function called serializeForm which will create JSON key/value pair out of serializeArray() and do the rest of the work.

$.fn.serializeForm = function()
{
    data = {};
    url = this.attr("action");
    items = this.serializeArray();
    $.each(items,function(i,item)
    {
        data[item['name']]=item['value'];
    }
    );
    return data;
}

now lets hook the normal submit process of the form using the following hook

function submitHook(form, callback)
{
    $(form).submit(function(e){
        items = {};
        items = $(form).serializeForm();
        url = $(form).attr("action");
        if(""==url)
        {
            alert("Cannot submit form. No action specified");
            return false;
        }
        callback = callback?callback:function(){};
        $.post(url,items,callback);
        return false;
    });
}

now you can just hook the form simply by this

ourCallback = function (data)
{
   alert(data);
}

submitHook($('#f1'),ourCallback);

happy jQuerying :)

→ 1 CommentCategories: Javascript · Tricks · idea
Tagged: , , , ,

hosting source code and projects for free – compare the available options

September 23, 2009 · 19 Comments

when you work as an individual (or even a small team/company), it often requires you to host your project files, source code (using svn/git/mercurial) for free, discuss with people and definitely to use some issue trackers, task list managers. fortunately there are some cool options available out there. some of them comes for free with paid plans as well, some of them have no free plans. some comes with minimal but very essential features and some of them are feature bloated.

i am going to share my comment about some of these applications for you so that you can choose the best that fits for you. and btw, i’m mentioning only those which comes with free plans

spring loops1. springloops : this is my most favorite one. springloops comes with both free and paid plans. free plan is enough to manage a small team because they support unlimited peoples in each project. and even in free account in spring loops, you can create up to three active projects. so whenever you are done on any project – just close that project or suspend and open another one. springloops has excellent deployment support. and it can notify or invoke a callback url once after each commit. and that feature is very very useful if you want to take action after “post commit” (which is called a web hook).

and you can create numbers of accounts with under same email address.

pros: excellent source code browser, deployment, support for subversion, nice todo list, 100 MB of space to host your files and source code, integration with basecamp and unlimited number of peoples
cons: no issue tracker, no support for git

spring loops2. unfuddle : another neat and cool project hosting service which i’ve been using for a long time. unlike springloops unfuddle has also support for git, storage is even higher by 100 MB more. unfuddle has really cool bug tracker, wiki pages, todo list manager and built in support for iCal and rss feed. but the most frustrating thing with unfuddle free plan is that only 1 active project and 2 people is allowed. this is mainly one of the reasons why I am sticking with springloops. and unfuddle also has no support for managing deployments but i really find that a minor issue.

pros: support for both svn and git, 200 MB of storage, todo list, bug tracker, wiki pages and iCal+feed support.
cons: no support for managing deployment, only 1 active project and 2 people is supported in free plan.

spring loops3. beanstalk : beanstalk is another very cute looking subversion hosting solution. beanstalk free plan comes with 100 MB of storage space for hosting your source code, 3 active users ad only 1 repository. btw, beanstalk has web hook suport only for paid plans.

pros: nice interface, daily backup, email/rss notification and guest access, integration with many external project hosting and issue tracking solutions.
cons: only 1 repository, only 3 active people. deployment and web hook only for paid accounts :(

spring loops4. goplan : goplan has no support for version controlling and it is more like a project management solution, and it has a very nice interface. goplan supports 3 concurrent projects but 2 people (and i hate that) and 2 collaborators. it gives you 100 MB of storage space. goplan comes with excellent todo list manager, time tracker, discussion board, file versioning and activity stream.

pros: time tracking, discussion board, calendar, plain file storage, todo list
cons: no source code version control (i really wish they will add it)

spring loops5. huddle : huddle is another alternative of goplan (project hosting) with no support for version controlling. but huddle comes with some amazing features like free voice conferencing, whiteboard and editing documents online. huddle is feature rich but i really didn’t like their interface that much. whereas others are focusing on a small audience, huddle tried to be solution for everyone. but i still like the ones who are focusing on small audience, because it helps them to be niche. btw, huddle free plan comes with 1 GB of storage.

pros: task list manager, meeting, discussion, file sharing, online file editing, whiteboard, 1GB of storage space.
cons: no source code version control (i really wish they will add it), and “not so cool” interface

some other solutions you can check out xp-dev, bounty source, assembla (was one of my favorite when they had free plans) and projectlocker, github (free for only open source projects) sourceforge and the google code (sourceforge and google code are only for open source projects)

→ 19 CommentsCategories: git · subversion
Tagged: , , , , , , , ,