Tag Archives: Open Source

My contributions to WordPress 4.4

As most of you might have known, WordPress 4.4 just got released. It has a lot of cool new features like responsive images, REST API, Term Meta etc. Brian Krogsgard has a nice and comprehensive writeup about the new features and read it if you want to get more information about these new features.

Another important aspect of WordPress 4.4 release is that it had 471 contributors, the highest so far. I am happy to say that I am one of those 471 people and this is the second time I got props for a WordPress release. The previousΒ one was for WordPress 4.3 which was released in August this year.

In this post I am going to briefly talk about the tickets that I worked on for WordPress 4.4.

Human readable data size constants

The first ticket that I contributed a patch was 22405. My patch introduced constants for common data sizes, so that you can use human readable constants like KB_IN_BYTES instead of hard-coded numbers like 1024 * 1024.

The following are the new constants that got added.

  • KB_IN_BYTES
  • MB_IN_BYTES
  • GB_IN_BYTES
  • TB_IN_BYTES

In addition to adding these constants, I also went over WordPress core codebase and replaced hard-coded numbers with the above constants.

Change password reset email subject based on user information

WordPress already provides the retrieve_password_title filter that allows you to change the subject of the “password reset” emails. But the problem with that filter is that it doesn’t pass user information. So if you wanted to change the email subject based on user information then it was not possible till now.

I have added both user_login and user_data parameters to the retrieve_password_title filter and now this allows you to change the email subject based on user information. This was doneΒ as part of ticket 34252

Documentation fixes

In addition to the above tickets I also worked on 34363, which was just a documentation fix.

I am very happy to have played a (small) part in the release of WordPress 4.4. If you are interested in contributing to WordPress then checkout the contributor handbook.

Posted in WordPress | Tagged , | 2 Comments

How to encourage contribution in open source projects

Last month, I talked about why you should open source your pet project, and also explained, how I started maintaining the Arduino Makefile project.

After that, this past one month has been really busy. I guess instead of me explaining how busy it had been, I guess the following picture would give a better idea.

github-contributions

There were 70+ commits that got into the project and huge number of critical bugs got fixed. If you look very closely, you will also find that it’s not just me who have been doing this πŸ™‚

I always believed that github encouraged contribution to projects, but in the last one month I also learned a couple of new lessons on how you could encourage more participation and contribution to your open source projects.

Below are some of those learnings. Do take them with a pinch of salt though πŸ˜‰

Let people know that they can contribute

This might seem silly, but it is really important to let people know that your project is open for contribution. I have spent countless hours fixing bugs and sending pull requests to projects in github, only to know that the repo owner is not interested in contribution πŸ™‚ And it is still worse, when they just decide to be silent about it, without even leaving a small comment.

So let people know upfront whether you will be accepting contributions or not. You don’t have to write huge paragraph about it. Just a single line, which says “contributions are welcome” in the readme file should do it. I generally add some variation of the following in my projects.

All contributions (even documentation) are welcome πŸ™‚ Open a pull request and I would be happy to merge them.

Let people know how to contribute

The next thing to do is to let people know how to contribute. The following are things which you might have to let them know.

  • Which coding style they should follow
  • Tabs vs space or 2 vs 4 character indent or to have a semi-colon or not πŸ˜‰
  • Whether they should open a pull request or send you a patch/diff
  • Whether all pull requests should contain test or/and documentation
  • How they should word the commit message. I try to follow this guide by Tim Pope
  • Whether you need them to have multiple commits or one single commit

You could choose your own process, but keep in mind that the simpler the process the easier it is to follow it. I generally follow a very simple process and reword or change the commit message if needed.

One other thing, you might have to keep in mind is that, not everyone is comfortable with git/github. In those cases, I point them to the guide that I wrote to help people contribute to github projects.

Track feature requests and TODO’s

Sometimes people want to just get their hands dirty by contributing a simple fix or feature before they become comfortable. In order to help people get started I track all feature requests and TODO’s in github issues. I also use TODO comments in the code and if applicable also link it to corresponding github issue. I also add the following line in the readme file.

If you are looking for ideas to work on, then check out the following TODO items or the issue tracker.

In addition to helping people who want to contribute, this also helps me to keep track of issues and features for the projects. If applicable also try to create milestones and assign issues and feature requests to corresponding milestones. This will also be useful for users of your project, to know when to expect a feature to be implemented.

Respond to pull requests

If someone sends a pull requests or reports an issue, try to respond to it. When someone creates an issue or pull request, they have spent their free time and you should respect that fact.

Sometimes you may not be interested in accepting the pull request. In those cases at least let them that you can’t accept it and also let them know the reason why you don’t want to accept it.

Be polite

Eventually, you will receive a pull request which is just plain stupid. Even in those cases try to be very polite.

When people are just getting started they may miss out something and might make mistakes or may not understand something which will look too trivial. But if you are going to embarrass them or be hostile, then it is not going to be helpful for them. They might just stop contributing not just to your project but for any project. Be polite and encouraging, especially if they are just getting started and you might make someone’s day a little brighter πŸ™‚

Also leave a simple “Thank you” comment after you merge someone’s pull request. It is a little mark of respect that you show for someone who has taken an effort to fix your code.

Follow a proper versioning policy

Any project which will be used by more than one person needs a proper versioning. These days I have started to follow Semantic Versioning for most of my projects. It is very simple to use and very effective.

Show people how to do it, by doing it

Whenever I want to contribute to a project, I try to get a sense of how things are done by seeing the commit history. So if you want people to follow a certain process or style when they contribute, then you should follow it in the first place.

Hide your time machine πŸ˜‰

.. and don’t forget to hide your time machine πŸ˜‰

Sometimes a little humor in your comment to a issue might make it easy for you to communicate with someone on the other side of the globe.

Happy coding πŸ™‚

Posted in Random/Personal | Tagged , | 2 Comments

Why you should open source your next pet project

After looking into my github account, lot of people used to ask me why I open source my pet projects, especially after looking at my streak at github (my current streak is at 52 days πŸ˜‰ ) the frequency of the question has increased.

I used to come up with an answer by combining these words randomly (passion, show off, free, rebel, linux, anti-Microsoft, license). But today, I realized that there is another (more important) reason why you should open source your (pet) projects.

Your project might have a longer shelf life than your interest in the project and in some cases longer than your life itself.

You might lose interest in the project, but if you have open sourced it, then there might be someone else who will continue to maintain it. But instead if you had just kept it in your hard drive, then it will just become part of the cosmic dust.

Abandoned projects

I have read about many examples where projects are continued to be maintained by other people, when the original creator has lost interest. _why is one famous example. When he suddenly went offline in Aug 2009 people immediately started creating mirrors of his projects and even though he is no more (in the online world) his projects are still being maintained actively.

None of this would have happened if he had not open sourced his code.

Arduino Makefile

Let’s talk about the project that thought me this.

Sometime back, I came across a post which explained how you can program Arduino from command line by using a makefile. I immediately got hooked and started using it when even I was working on Arduino sketches.

Soon I found out a couple of issues and submitted pull requests. Some of my pull requests were accepted and others weren’t. While browsing through the issues and pull requests of the project in github, I found that there were lot of other people who have also contributed various patches to the project. It also seemed that the original author has stopped doing any development or answering pull requests.

I started to consolidate all pull requests and patches from various forks into a common fork and even updated the readme file expressing my desire that one day all these changes would get into the main repo πŸ™‚

Fast forward a couple of months.

Last week, I was surprised to receive an email from the original author, saying that he has lost interest in the project and whether I would be interested in maintaining the project going forward. I happily accepted and he transferred the repo to my account, after I merged all my changes back into the main repo.

None of this would have been possible if he didn’t choose to open source the project initially and also let go the project when he lost interest.

Thanks to Github

Ohh, by the way, I should also mention that some of it was possible only because of github. If github wasn’t there, then it would had been difficult for me to find and consolidate other forks and he also wouldn’t have noticed my fork or the effort that I was spending on the project.

Also, the recent addition of redirects by github made the repo transfer really seamless.

So remember to open source your pet projects by at least uploading them to github. Because you may lose interest in the project some day, but the project might still continue to live long after that.

Happy Open sourcing πŸ˜‰

Posted in Arduino, Random/Personal | Tagged , , , | 6 Comments

Contributing to project hosted in Github

As most of you know, I host most of my projects which I have released as open source in Github. I am open for collaboration and generally accept most of the pull requests that people send me.

Recently I noted that not all people who want to contribute are proficient with git or Github. So here is a small guide to help people who are interested in contributing to projects hosted at Github.

Before we proceed just keep in mind, that this is not the only way to do it. But if you are just starting out using git or Github, then this is a good starting point.

Fork the project in Github

The first step is to fork the project at Github. Go to the project that you want to contribute to and then click the fork button near the top right corner.
github-fork

Clone the forked project to your machine

When you fork the project, Github creates the forked project in your account. Once you forked the project, you need to clone it to your machine.

You can use the following command to do it.

git clone git@github.com:sudar/wp-irc.git

Replace it with your actual username and project name

Create a new branch

The next step is to create a new branch. You can use the following command to do that.

git checkout -b branch_name

Commit your changes

After you have made the changes, you have to commit them to the new branch

git add file_name

or

git add -p file_name

Then do

git commit -m "Your commit message"

Remember to have a meaning full commit message. If possible follow this guide by Tim Pope on how to construct a good commit message.

Push the change to Github

Next you have to push the changes to Github. You can do it by using the following command.

git push -u origin branch_name

Send a pull request

Now go to Github and send a pull request, by clicking the pull request button in Github. The owner of the repo will be notified and he may choose to accept or reject the request.

Keeping your repo upto date

Once the pull request is accepted, you can merge the changes back to your repo by using the following commands.

git remote add upstream git://github.com/sudar/wp-irc.git

git checkout master

git pull --rebase upstream master

git push origin master

Posted in Unix/Server Stuff | Tagged , , | 5 Comments

10 more open source Android apps which every developer must look into

Sometime back, I listed top 10 Open source Android apps, which every developer must look into. It’s been quite sometime since I wrote it and now I am adding a few more to the list.

Ubuntu One

Ubuntu One is a cloud storage service by Ubuntu. They have released an Android app which allows you to upload files to the cloud from your mobile and also manage your Ubuntu One account from your phone.

You can learn how to upload files, make Rest API calls, store auth tokens, detect WIFI activation etc by browsing the source code.

Source code Url: https://code.launchpad.net/ubuntuone-android-files

Mixare

Mixare is an open source Augmented Reality Engine for Android. It is pretty well build and complete.

You will learn how to draw custom shapes on top of the live video feed captures by the camera by browsing the source code. You can also learn about creating Plugin models in Android apps.

Source code Url: http://code.google.com/p/mixare/

Desksms

DeskSMS is an android app that forwards all your text messages and call history to your GTalk, GMail, or a convenient website and browser extension. It written by koushikdutta.com, the author of Rom Manager

You can learn how to read, send and forward sms and call log by browsing the source code. In addition to the android app source code, checkout the other browser extension source code as well.

Source code Url: https://github.com/ClockworkMod/DeskSMS

Call Meter NG

Call Meter NG/3G is an Android application summing up your call and text logs.

You can learn how to read call logs, SMS logs, MMS logs and data logs by browsing the source code. In addition to it, you can also learn how to create variable length widgets, which is one of the cool things about the app.

Source code Url: http://code.google.com/p/callmeter/

Scrobble Droid

Scrobble Droid is an Android app, that keeps track of music you listen and sends the details to Last.fm

You can learn how to track music that is currently playing in Android by browsing the source code. In addition to it, you can also learn how to consume Last.fm API from ndroid.

Source code Url: http://code.google.com/p/scrobbledroid/

Gmote

Gmote is an Android app that turns your Android phone into a remote control for a computer, allowing users to run movies and music at a distance.

You can learn how to transfer touch and other gestures from phone to computer and also about music streaming between phone and computer by browsing the source code.

Source code Url: http://code.google.com/p/gmote/

Ema Personal Wiki

Ema Personal Wiki is a notebook with linkable pages for tracking your ideas, todo lists, tasks, bookmarks, brainstorms etc. The notes are stored in markdown format and can be synchronized using Dropbox account.

You can learn about using markdown and syncing files using Dropbox Api by browsing the source code.

Source code Url: https://github.com/janwillemb/Ema-Personal-Wiki

Chrome to Phone

Google Chrome to Phone Extension is a project consisting of a Chrome Extension, Android App, and supporting AppEngine server that enables users to send links from their Chrome desktop browser to their Android device using Android’s Cloud to Device Messaging service.

You will learn about using C2DM and sharing url from browser by browsing the source code.

Source code Url: http://code.google.com/p/chrometophone/

Android Tetris

It is a Tetris clone for Android.

You will learn about drawing on the canvas by browsing the source code.

Source code Url: http://code.google.com/p/androidtetris/

NFC Tic Tac Toe

This is a sample Tic Tac Toe game implemented using NFC.

You will learn about transfering data using NFC by browsing the source code.

Source code Url: https://github.com/iBadrinath/NFC-TicTacToe

Posted in Android/Java | Tagged , , , | 19 Comments

10 Open Source Android Apps which every Android developer must look into

I used to read code from popular open source projects to see how others implement certain functionalities and also to learn from them. (I am a firm believer of the fact that you have to read good code to write good code)

Recently I have been following up a couple of good open source Android apps and thought of listing them here so that it could be useful for others.

Update: I have updated this list with a new set of apps, which have come out recently. Check out them as well.

Sample Apps by Android Team

Could there be a better way to start without looking at the code of the developers who developed the framework? πŸ˜‰ These are 15 different android sample apps created by the core developers of the Android framework. These include a couple of games, photostream, time display, home screen shortcuts etc.

url : http://code.google.com/p/apps-for-android/

Remote Droid

RemoteDroid is an android app which turns your phone into a wireless keyboard and mouse with touchpad, using your own wireless network. You can learn lot of things like connecting to a network, controlling user finger movement etc from its source.

url: http://code.google.com/p/remotedroid/

TorProxy and Shadow

TorProxy is an implementation of Tor for Android mobiles. Together with Shadow, it allows you to browse website anonymously from your mobile phone. You can learn about tunnelling socket connections, managing cookies etc by reading its source code.

url: http://www.cl.cam.ac.uk/research/dtg/code/svn/android-tor/ and http://www.cl.cam.ac.uk/research/dtg/android/tor/

Android SMSPopup

It is an Android app that intercepts incoming text messages and displays them in a popup window. Apart from being a time saver, this app also shows us how to interface with the built-in app that manages SMS.

url: http://code.google.com/p/android-smspopup/

Standup Timer

Standup Timer is an Android application that acts as a simple, stand-up meeting stop watch. It can be used to ensure your stand-up meeting finishes on time, and gives all the participants an equal share of time to state their progress. You can learn how to use the timer functionality by reading the source code. Also this apps has clear distinction between view, model etc and has lot of util methods which we can reuse in our app.

url: http://github.com/jwood/standup-timer

Foursquare

It is a four square client for android. This app is basically divided into two components; Reading the source code you can find out how to make

url: http://code.google.com/p/foursquared/

Pedometer

The pedometer app tries to take the number of steps you take every day. Even though the count is not accurate, you can learn different things like interacting with accelerometer, doing voice updates, running background services etc by reading its source code.

url: http://code.google.com/p/pedometer/

opensudoku-android

OpenSudoku is a simple open source sudoku game. You can learn how to display things in a grid in your view and also how to interact with a website by reading its source code.

url: http://code.google.com/p/opensudoku-android/

ConnectBot

ConnectBot is a Secure Shell client for the Android platform. There are lot of good things about this app’s source code. Check it out for yourself πŸ™‚

http://code.google.com/p/connectbot/

WordPress for Android

How can you expect a list of apps from me without mentioning WordPress πŸ˜‰ This android app is from the official WordPress development team. You can learn how to make XMLRPC calls (in addition to other cool things) by reading its source code.

url: http://android.svn.wordpress.org/trunk/

If you got any good open source android apps from which we can learn something, then do leave a comment and I will add them up here, till then happy reading πŸ™‚

Update: I have updated this list with a new set of apps, which have come out recently. Check out them as well.

Posted in Android/Java | Tagged , , | 122 Comments