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

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)

converting standard wordpress into a SQLite powered multi user blogging platform

wordpress is one of the very popular blogging platforms which is not only free but also released as a open source project. officially wordpress runs only on mysql. so if you want to run it with SQLite, you will not find any official support for that. but fortunately justin addie has written an excellent plugin (pdo for wordpress) which will work as an adapter just between the wordpress DAL and mysql. this plugin hooks all the SQL queries which are sent to execute on mysql by wordpress, convert those into PDO compatible statements and then execute them. currently PDO for WordPress is written to work smoothly with mysql and sqlite.

on the other hand, WPMU (wordpress mu or multi-user) is another version of wordpress which uses the core wp with some modifications and convert any single user wordpress blog into a multi user blogging platform. in this blog post i will show you how you can convert a general installation of wordpress into multi user blogging platform (like WPMU, but fully featured) and take advantage of SQLite :) – so let the fun begin.

step 1: check if your domain support wildcard A record. if so, then create a “*” A record and point it to your server. if it works, now you can point http://.. to your server :) – that is very much required. alo please check that in your webserver it has “pdo” and “pdo_sqlite” php extensions enabled. you can check that using phpinfo(); – needless to say, you need PHP5

step 2: install wordpress

step 3: install pdo for wordpress
download the pdo_for_wordpress plugin. inside it you will find one file named “db.php” and a folder named “pdo”.
put the db.php inside “wp-content” directory
now put the “pdo” folder inside “wp-content” directory

open wp-config.php
find the following line

define('DB_COLLATE', '');

add the following line just below that line

define('DB_TYPE', 'sqlite'); 

step 4: create a directory named “userdb” anywhere in your server, make sure to give it write access. in this example we’ve created one as /opt/userdb – DONT FORGET TO ASSIGN WRITE PERMISSION to this “userdb” directory.

step 5: now we will be modifying that “db.php” which we had copied into “wp-content” folder.

find the line in db.php where it says

define ('FQDBDIR', ABSPATH .'/wp-content/database/');
define ('FQDB', FQDBDIR .'MyBlog.sqlite');

now change those lines as below

define ('FQDBDIR', '/opt/userdb/');
define ('FQDB', FQDBDIR ."{$_SERVER['SERVER_NAME']}.sqlite");

and tada – you are done. now point your browser to any subdomain under your domain and it will comeup with registration page. register some blog and check it out :) (at the bottom of this post you can find the link of a live demo)

now you can extract some themes in the wp-content/themes folder or some plug-ins into wp-content/plugins folder. all users will be able to choose only from those pre installed themes and plugins, and everyones data and configuration will remain separate from others, as everyone is running from their own database. set only “read” access to “wp-content/themes” and “wp-content/plugins” folders to avoid any security loophole.

happy blogging.

[note - i've checked it against latest wordpress 2.8.4 and it runs okay]

To check out a live example of a running wordpress 2.8.4 on SQLite – click on http://anything.twistats.com/wp/ – and to create your own – just go to this url http://<any_subdomain&gt;.twistats.com/wp and register your one :). You can select from six pre installed themes too :)

removing empty elements from an array, the php way :)

removing empty elements from array is most likely a very common task for everyday programming. different people work on it differently. some runs N times loop and some other tries by finding offset and then by unsetting that. let me show you some common approach of doing it and possibly the best way too :), needless to say, in a php way – most of the time such a microsecond does not matter, but well, its still good to find out the best solution :)

first of all, lets write a function which will create a random array with empty elements

function generateRandomArray($count=10000)
{
    $array = range(0,($count-1));
    for($i = 0;$i&lt;1000;$i++)
    {
        $offset = mt_rand(0,$count);
        $array[$offset] = "";
    }
    return $array;
}

now lets see some different approaches to get it done.
probably most common approach

$array = generateRandomArray();
$len = count($array);
$start = microtime(true);
for ($i=0;$i< $len;$i++)
{
    if(""==$array[$i]) unset($array[$i]);
}
$end = microtime(true);
echo ($end-$start);

you can see the output varies from 0.13-0.14 seconds for an array with 10000 elements in a 2.66 ghz core 2duo machine running mac osx 10.5.8 with 4GB ram.

here is another better approach using array_diff()

$array = generateRandomArray();
$start=  microtime(true);
$empty_elements = array("");
$array = array_diff($array,$empty_elements);
$end = microtime(true);
echo ($end-$start);

this one takes 0.052-0.059 seconds and surely is a significant improvement over the last one

here is another improved version using array_filter()

$array = generateRandomArray();
$start=  microtime(true);
$array = array_filter($array);
$end = microtime(true);
echo ($end-$start);

it takes like 0.002 seconds to complete :) – pretty good one, eh? (thanks damdec, for reminding about it)

and this is the last one which was my favorite one using array_keys() taking advantage of the optional search_values parameter :)

$array = generateRandomArray();
$start=  microtime(true);
$empty_elements = array_keys($array,"");
foreach ($empty_elements as $e)
unset($array[$e]);
$end = microtime(true);
echo ($end-$start);

this is an amazing improvement over the previous solutions, it takes only around 0.0008 – 0.0009 seconds for an array of 10000 elements.

i hope you enjoyed this post with micro benchmarks :D – happy phping

some very useful apps for mac osx, free as well :)

i am a big time fan of mac osx. if you think there are no free+useful app for mac, you are quite wrong. here is my personal favorite list of some free and very useful apps which i use everyday.

CyberDuck CyberDuck: it is my most favorite FTP and SFTP client, and its really very cool. Well, you can use it as a WebDAV and S3 client too. Its open source and you can check it out from here

ALunch: if you use your dock very frequently and are really tired to reconfigure it again and again, alunch is a very nice sticky app launcher for you. it’s organiser is simply awesome and you can arrange all your applications in a a well categorized manner easily. its very nice and one of my very favorites. Check it out from here

ALunch

iStat Pro and Menus: though it has a name “pro” but it comes for free. it is an awesome device monitoring tool and supplies you very essential information about your mac device, like bandwidth consumption (both eth and bt) temperature, fan RPM, memory usage, cpu usage and it supplies each of these with details. download it from here – btw, forgot to tell you that you can install it in your iphone and ipod touch too!

iStat Pro

Chicken of VNC: it is a nice VNC client for mac. if you have multiple macs in your home or you want to use it as a generic VNC client to your other machines, from you mac – it is the perfect tool. open source and free :)check it out from here

Caffeine: it is another very useful and handy when you really dont want your screen to black out (heh heh). it sits on your top bar with a icon of coffee cup, and once you click on it the machine will stay active for 30 minutes (configurable). no screensaver, no dimming – its show time :D. check it out from here

Caffeine

Using Google WorldMap visualization component in your applications

Its really hard to find a good flash based world map component to use in your web applications. They are either too complex to add or they cost quite a lot. And even sometime if you pay that, its tough to customize the chart as you want it to look like. But you know there is someone called “Uncle G” (i.e google) here who has almost all the components in his Pandora’s box. So lets see how can we use the geomap component from their Visualization Library.

First we need to create a datatable which will act as a data source for this world map, as usual like all other google visualization component.

var data = new google.visualization.DataTable();
data.addRows(5);
data.addColumn('string', 'Country');
data.addColumn('number', 'Number of ZCEs');
data.setValue(0, 0, 'Bangladesh');
data.setValue(0, 1, 19);
data.setValue(1, 0, 'India');
data.setValue(1, 1, 150);
data.setValue(2, 0, 'Pakistan');
data.setValue(2, 1, 4);
data.setValue(3, 0, 'Nepal');
data.setValue(3, 1, 5);
data.setValue(4, 0, 'Sri Lanka');
data.setValue(4, 1, 7);

now we will initialize the google visualization framework and draw this component using this data source

var geomap = new google.visualization.GeoMap(document.getElementById('<container_div_id>'));
geomap.draw(data, null);

but wait, we are not done yet – to make sure that everything works properly, we need to wrap all of these code inside a function (for example name this function as drawGeoMap) and we will use that function as a callback to draw this map. and of course, we need to load the google visualization library and geomap component first

so here is the complete code of this

<html>
<head>
  <script type="text/javascript" src="http://www.google.com/jsapi"></script>
</head>
<body>
<div id="map" style="width: 800px; height: 600px;"></div>
  <script type="text/javascript">
    google.load('visualization', '1', {packages: ['geomap']});

    function drawGeoMap() {
      var data = new google.visualization.DataTable();
	  data.addRows(5);
	  data.addColumn('string', 'Country');
	  data.addColumn('number', 'Number of ZCEs');
	  data.setValue(0, 0, 'Bangladesh');
	  data.setValue(0, 1, 19);
	  data.setValue(1, 0, 'India');
	  data.setValue(1, 1, 150);
	  data.setValue(2, 0, 'Pakistan');
	  data.setValue(2, 1, 4);
	  data.setValue(3, 0, 'Nepal');
	  data.setValue(3, 1, 5);
	  data.setValue(4, 0, 'Sri Lanka');
	  data.setValue(4, 1, 7);
      
      var geomap = new google.visualization.GeoMap(
          document.getElementById('map'));
      geomap.draw(data, null);
    }
    

    google.setOnLoadCallback(drawGeoMap);
  </script>
</body>
</html>

you can check the demo at http://sandbox.ofhas.in/geomapv1.php

it will display a world map with highlighted countries like below
Geomap V 1

but wait – lets make ca nifty change and add event listeners to it. we will add event listeners in such a way so that whenever users click on any country in the map, it will take you to zend yellow page corresponding to that country :) that will make it really an useful component :). here is the code

<html>
<head>
  <script type="text/javascript" src="http://www.google.com/jsapi"></script>
</head>
<body>
<div id="map" style="width: 800px; height: 600px;"></div>
  <script type="text/javascript">
  	var data, geomap;
  	var cids = [18,102,166,152,203]
    google.load('visualization', '1', {packages: ['geomap']});
    

    function drawGeoMap() {
      data = new google.visualization.DataTable();
	  data.addRows(5);
	  data.addColumn('string', 'Country');
	  data.addColumn('number', 'Number of ZCEs');
	  data.setValue(0, 0, 'Bangladesh');
	  data.setValue(0, 1, 19);
	  data.setValue(1, 0, 'India');
	  data.setValue(1, 1, 150);
	  data.setValue(2, 0, 'Pakistan');
	  data.setValue(2, 1, 4);
	  data.setValue(3, 0, 'Nepal');
	  data.setValue(3, 1, 5);
	  data.setValue(4, 0, 'Sri Lanka');
	  data.setValue(4, 1, 7);
      
      geomap = new google.visualization.GeoMap(
     	document.getElementById('map'));
     	 google.visualization.events.addListener(geomap, 'select', selectHandler);
      geomap.draw(data, null);
      
    }
    

    google.setOnLoadCallback(drawGeoMap);
   
    
    function selectHandler()
    {
        var selection = geomap.getSelection();
        var item = selection[0];
        var cid = cids[item.row];
        var url = "http://www.zend.com/en/yellow-pages#list-cid="+cid+"&firstname=&lastname=&orderby=name&sid=XX&company=&photo_first=&certtype=&ClientCandidateID="
        window.open(url);
        
    }
  </script>
</body>
</html>

check the demo at http://sandbox.ofhas.in/geomapv2.php

now you can click on any country and it will open a new tab with that particular country pre selected – and you can see who are the zend certified engineers from that country. i hope you’ve liked this :). Thanks goes the theam Visualization team at google for creating these awesome components and to make them free for use

For reference – check out geomap reference at google code at http://code.google.com/apis/visualization/documentation/gallery/geomap.html. you can do many other cool things like displaying only US states map or Canadian States map with this :)

leaving i2we on 15th next

i’d joined i2we family on july 15th, 2008. i2we was a small venture funded company from berkeley and founded by karel baloun, one of the very first engineers in facebook. it was quite a good time over there with a nice team (specially louise, vladimir, jessica, himani, karel, ray , taewoo, sean, gerardo, cecilia, diego and definitely my bangladesh team shahid, shoeb and mahmud) – i have met some very skilled and prominent backend engineers (vladimir, gerardo – it was great working with you) and co operative team mates (louise, it is really hard to find such a good team mate like you). and yeah – taewoo. the one codeigniter wizard i’ve seen so far. and jessica, it was nice to meet you on board. shahid and shoeb are leaving too and definitely i wish someday teaming up the old team again very soon. stay tuned, my friends.

basically i’ve developed facebook applications and standalone RnD based web apps during this time, helped the whole team to optimize the platform and to tune it up. and it was overall a good time experimenting new tools and learning many insider things. thanks to karel and ray for their awesome support.

i am planning to have a vacation for a month right now with my family and then it’s the same old story again – :) and yeah, will start looking for job again. so wish me the best :)