CodeIgniter 2.0 Is Baking

March 12th, 2010 | Save to del.icio.us now

Just when I was loosing all hopes about CodeIgniter, yesterday EllisLab announced about their move to assembla and mercurial, in that there was a small but significant news about CodeIgniter 2.0.

A quick look into the change log revealed

PHP 4 support is deprecated.  Features new to 2.0.0 may not be support PHP 4, and all legacy features will no longer support PHP 4 as of 2.1.0.

This is what I was waiting for. What it means, as pointed by Phil Sturgeon and Elliot Haughin, is that CI 2.0 will not run on PHP 4, but more importantly, it can now take full advantages of PHP 5.

One other thing that I liked is

Added ability to set "Package" paths - specific paths where the Loader and Config classes should try to look first for a requested file.  This allows distribution of sub-applications with their own libraries, models, config files, etc. in a single "package" directory.  

Which means that now we can create common area where we can keep helpers, views and libraries that needs to be shared between two applications.

While there are many more updates these two got me excited.

For now let’s wait for them to release, meanwhile you can sign up for Bitbucket and follow the updates for CodeIgniter Project.



How to get Latitude/Longitude from an address (or Geocoding ) using PHP

March 10th, 2010 | Save to del.icio.us now

While Google’s documents for maps API does good job in showing how to get lat/long from an address in JavaScript they do not really show any example of doing the same with PHP.

 

So to make you life simple here is a small script in PHP that does that.

 

 

$geocode=file_get_contents('http://maps.google.com/maps/api/geocode/json?address=573/1,+Jangli+Maharaj+Road,+Deccan+Gymkhana,+Pune,+Maharashtra,+India&sensor=false');

$output= json_decode($geocode);

$lat = $output->results[0]->geometry->location->lat;
$long = $output->results[0]->geometry->location->lng;

 

The line above makes a request to Google maps API. Passes the address, and receives the response in JSON format.

The URL has following options

http://maps.google.com/maps/api/geocode/output?parameters

where output can be 1) JSON or 2) XML

For more details about parameters check out the Google’s geocoding documentation.



Backup your WordPress blog to Rackspace Cloud Files

March 5th, 2010 | Save to del.icio.us now

We all have heard of importance of regular backups, but for a long time I had neglected it for my blog. But recently things happened that prompted me to take backups.

While I was looking for option to keep backups, I found Rackspace Cloud Files to be a very affordable option, this prompted me to write wpSimpleBackup a WordpPress plug-in that  will take the backups to cloud files, and then I also added support to take backup to Amazon S3 or FTP to another server. But unlike my other plugins, this one is not free.

wpsimplebackup

Features

  • Backup your entire blog not just database. It takes backup of the wp-config.php, database, and plugins, themes and all other files in wp-content folder.
  • Simple and speedy restore. All you have to do is to move the restore script to the location where you need to do restore, it will automatically fetch the backup file and restore your blog.
  • Even simpler migration. if you have ever moved you web server or domain you know the pain it is, with the restore script you get the simple Wordpress like installation script which not only installs the Wordpress but also restores all you backed up settings, even updating the domain urls if needed. Migration will never get easier then this.
  • Not one but three ways to keep your backups, while I personally use Rackspace CloudFiles, you have a choice to use Amazon S3 or even FTP.
  • Ability to take manual Backups.  While we do have ability to automatically take backups, some times it makes sense to take backups manually, just click a button, and back up is done.
  • Restrict number of backups. while we allow for any number of backups, in services like S3 or Cloud Files, keeping large number of backups can become costly over a period of time. To avoid that you can specify number of latest backups you want to keep, and the backup plugin will take care of the rest.
  • Backup Scheduling. It provides the ability to take backups automatically every day, once a week or month.

You can buy wpSimpleBackup plugin here.



PHPCamp is Back

December 31st, 2009 | Save to del.icio.us now

Preparations are on for second edition of India’s biggest un-conference for PHP developers.

365418978

It is going to be held on 9 January 2010 at Symbiosis Centre For Distance Learning, Pune.

Check out the talks and if you think you can give a better one then please propose your talk.

If you have not registered yet, then it is the right time to register. Like last year we hope to have a big gathering and lot’s of fun.



How To Fix MySQL Error – Error Code 30

December 3rd, 2009 | Save to del.icio.us now

Yesterday was one of those days when things that can go wrong went wrong and today was MySQL day, and problem when accessing any table on a live site resulted in following error

MySQL Error - Can't create/write to file '/tmp/#sql_7d3f_0.MYI' (Errcode: 30)

It took me some time to figure out that the error was due to /usr/tmpDSK getting corrupted, and and not really a problem with MySQL or our database as we were thinking all this time, and as usual google came to rescue.

Here are the steps to fix this for cpanel users…  run the following commands in the order mentioned

/usr/sbin/lsof /tmp

/bin/umount -l /tmp

/bin/umount -l /var/tmp

/bin/rm -fv /usr/tmpDSK

/scripts/securetmp

This will create a new /tmp partition for you and the problem will go away. By the way error code 30 means that file system is read only.



Barcamp Pune 6

November 12th, 2009 | Save to del.icio.us now

The 6th Edition of Barcamp Pune is back in town on 14th November 2009 after almost an year.

If you don’t know what is Barcamp check out the nice article by PuneTech and if you are students then why you should bunk the college to attend it.

My first Barcamp was Barcamp Pune 3, which made me an speaker and also inspired me to organize biggest PHPCamp in India.

krity-barcamp-logo-medium

If you want to know what happened in pervious editions of Barcamp then check out the pictures linked below( from my camera).

  1. Barcamp Pune 3
  2. Barcamp Pune 4
  3. Barcamp Pune 5

Off course they are not all the pics, Google to see all the rest of them.

I hope to see you all their.



Where is MySQL Gone Away?

November 11th, 2009 | Save to del.icio.us now

Last Sunday I got to work on a very interesting problem in WordPress which I initially thought could be solved in like 5 mins, but alas it took me almost 7 hours before I found and fixed the problem.

Let me describe the problem, I was running a simple xml parsing script whose task was to parse the xml file and insert the content into WordPress database as a post, everything was working fine except the ‘INSERT’ statement was failing with out any errors. Basically everything would run but nothing would get inserted into database and no errors. We had used the ‘wp_insert_post’ function in  ‘post.php’ file to handle the insertion of post, which was returning ‘0’ instead.

After lot’s of time spend checking and cross checking the sql statements for error and PHP code logic, i finally found the problem which was a small kinda cryptic error ‘MySQL server has gone away’ for every single query that was getting executed in the script.

Well, a quick google search took me to MySQL manual page where it list bunch of possibilities on why the error might be coming.

To me the most logical one were

    1. You tried to run a query after closing the connection to the server. This indicates a logic error in the application that should be corrected.
    2. A client application running on a different host does not have the necessary privileges to connect to the MySQL server from that host.
    3. You have encountered a timeout on the server side and the automatic reconnection in the client is disabled (the reconnect flag in the MYSQL structure is equal to 0).
    4. You can also get these errors if you send a query to the server that is incorrect or too large.
    5. You are using a Windows client and the server had dropped the connection (probably because wait_timeout expired) before the command was issued.

I investigated each one but it turned out that because a query was taking a bit to long to execute MySQL closed the connection and refused all further request from the client.

So you might be wondering what was the Solution to this problem.

Well Rob of Rob’s notebook had the almost perfect solution for it. He created a replacement file for ‘wpdb.php’ which takes care of this problem, yeah it is temporary and you have to remember to replace this file every time you do an WordPress upgrade but it works.

If you are facing this problem go download it and replace you ‘wpdb’ file and save yourself some time.

Check out PHPCamp.net a article sharing website relevant to our own PHP community


Media Manager Browse Button Disabled In Joomla

August 19th, 2009 | Save to del.icio.us now

Problem : No matter how many time you click on the media manager’s browse button nothing happens. It used to work few days back but not any more.

It is as if the the media manager buttons has been disabled.

media_manager_problem

If you were facing these problems it is most probably due to the Flash uploader not working properly with Flash version installed on your system.

Solution:

The simplest solution to fix this issue is to go to,

Global Configuration –> Systems –>Media settings.

And select ‘No’ for ‘Enable Flash Uploader’ setting, and save the settings.

mediamanager_config

That’s it, this simple. Now go back to you media manager and upload files to your heart’s content.



How to use SVN and Git together to get the best of both worlds in Windows

August 17th, 2009 | Save to del.icio.us now

I have been using SVN to manage my source code for last three years, I can say I am quite happy with it, except for one problem, it was not possible to commit the code unless I was directly connected to my office network.

Then I heard about DVCS and Git. I found solution to one of my big problem, ability to commit code while I am not connected to office network, and share code with my teammates.

Their was only one small problem we didn’t wanted to loose the benefits of centralized repository, and we use Windows  OS( let’s not get into windows vs linux, i will win). So last 3-4 months I was looking for different DVCS systems with better windows support and i experimented with Mercurial (TrototoiseHg is good), but i think Git wins the race of DVCS hands down, and with popularity of GitHub I don’t see much choice here.

And finally I found about git-svn, and I was on my way.

Here are the commands and steps that you can use to manage Git and SVN together.

  1. Create a working copy(or actually a git repository ) using
    git svn clone –s <path to ur svn rep, eg https://akjoomgallery.googlecode.com/svn/trunk/>
  2. Get the source from svn repository to your git repository using
    git svn fetch

    (only needs to be done first time, it is slow and time consuming process)

  3. When you need to update your working copy  you use
    git svn rebase
  4. When you need to commit back to svn repository just use
    git svn dcommit

I used above commands in Git bash shell that comes with Git.

Also note their would be time when we have some changes in the Git repository that is not yet ready for commit, but we need to update our repository and Git won’t let you do that, without committing them (rebase will always give error) in such situation you use following set of commands

git stash

git svn rebase

git stash apply

git stash clear

Update:

And if you don’t want to these things manually here is my favourite tool that does that using nice GUI and perfect windows integration TortoiseGit

I have written this a month back before I found TortoiseGit, so this is now just for reference, and to get me back to my blogging.

Have fun.



Joomla Day Pune(India)

April 29th, 2009 | Save to del.icio.us now

On 25th April 2009 we hosted first ever Joomla Day in India. This was made possible by support of Parth and Ashwin who forced me to also think about Joomla Day in last years PHPCamp, where we were planning for Drupal camp.

They were later joined by Shardul, who was already pushing for Joomla day in India at events forum in joomla.org. He was the person who was on our first coffee meet to discuss how to get going so that we get official approval from OSM. He also pushed me to create and register Joomla User Group Pune, for the event.

We met multiple times to talk and plan how things should happen.Volunteers Team on 24th evening for Joomla day

In middle of all this, out of nowhere, Mangesh joined us. He was instrumental in actually making joomladay.co.in website usable, as Ashwin and Parth could not give the time and attention to it. He also ended up hosting the website on his server, when we started having trouble with dream host.

With organizers team ready, we needed few volunteers,  this is where Tara came into picture, he helped us with venue and insisted that we give I2IT a try. Krity worked on the content of the website and faq’s. Kinjal helped us with photographs, Rucha and Shruti helped us managing the registrations on the day of event.

Finally I want to thank Toby Patterson for coming all the way from Thailand to help us with Joomla Day.

Guys to stay updated about Joomla User Group Pune activity follow us on Twitter or Subscribe to our google group mailing list as Joomla Day is just an start.