Logging user to LDAP directory under Yii

On certain systems and LDAP configurations you are required to use two-step login approach. It goes like this:

  1. Bind anonymously, by specifying only $bind = @ldap_bind($connection);.
  2. ldap_search for a given username. Search will return you a valid user’s DN (or NULL, if user does not exist).
  3. Using returned LDAP call another ldap_bind, this time attempting to actually login user.

Thus, in this approach you are not constructing your own DN, but relying on returned one instead.

List of all countries in the World, split by continent

Here is the list of 197 countries in the world, split by five continents, put as simple, not formatted list (for future use as data for some form or selection) and as HTML code.

Note, that this list contains only “full featured” countries, without any dependent territories, special municipalities, incorporated territories etc. So, you won’t find here many of the Oceania’s or Antarctic islands. Also very small, Caribbean-based dependent territories are not listed here.

Note also, that this list contains both North America’s and South’s America’s contries put together.

Read More “List of all countries in the World, split by continent”

Downloading large files with PHP

First define, what do you mean, by “large” and “huge”? In this post I present the quickest solution of using file chunking. It works fine (tested!) for files of size up to 2 GB. If this is enough for you, fine — go ahead. If you need to download something bigger, consider using mod-xsendfile (only on Apache — more here and here).

Chunking files is the fastest / simplest method in PHP, if you can’t or don’t want to make use of something a bit more professional like cURL, mod-xsendfile on Apache or some dedicated script.

Read More “Downloading large files with PHP”

An introductory comparison of BitBucket and GitHub

I decided to migrate from GitHub to BitBucket purely for economic reasons. On GitHub I can’t have any private repository in my free account. I have to pay for every non open source project, that I host there.

On BitBucket I can have unlimited number of private repos and I’m only paying for users, that has access to each of my repository (first five users are free).

This is the key advantage for me. And while BitBucket has many more of them, it also has some certain disadvantages. So, if you’re thinking about on-line repository management and want to choose between BitBucket and GitHub, this article can be a good start point for you.

Login and account

Both on-line VCSes has the same approach as for login and account creation. ​They only supports own / Google / Facebook / Twitter / GitHub login via OpenID. If you’re looking for a solution, that supports custom login methods, like for example to be able to let your forum users use also repository management and / or bug tracker and / or wiki, both GitHub and BitBucket are not an option for you.

However, if you give any of them a try, you may be surprised how many users have their own BitBucket account or can login via above accounts. Bitbucket itself is quite popular. And I don’t think there are many users of your forum, that don’t use any of above mentioned​​ services. So they actually don’t need to create an additional account. They just login with their favorite social network.

Next thing is, that we’re talking about devoted bug-reporters, that will be willing to reply your comments, provide screenshots, additional information etc. etc. If someone is devoted enough to your project, he or she will not object before creating another account / using another service to make your stuff even better. Actually, this is the only thing that matters.

Key differences

GitHub, which has much more users world-wide. The key difference between Bitbucket and GitHub, is how do they handle private repositories:

BitBucket allows an unlimited number of private repositories, but limits you to only up to five contributors to each repository. You are paying (starting at $10 / month) for sixth and more contributors — .

GitHub, on the other hand, let you have an unlimited number of contributors, but limits you to only public (open source) repositories. You’re paying (starting at $7 / month) for first and more private repositories — .

Both repository management systems allows you to use additional tools like bug tracker for issues management and wiki-like software for managing of documentation of your project. Both allows you to run public tracker / wiki, with non-public or even empty source code repository. So, you can have fully featured bug tracker (and wiki) open to public (to all with access to BitBucket / GitHub — i.e. above mentioned OpenID’ accounts) without need to make your source code public.

BitBucket’s issue tracker have an option to import and export issues in JSON format. So, while it can’t be used directly in any other bug tracking systems, it is quite adoptable, easy to read and import / export to any of them, after just a little bit more work. I have no idea about exporting things out of GitHub, as I never needed such functionality. I used BitBucket’s mechanisms to import all my GitHub repos.

There are two key advantages of using BitBucket over GitHub:

In BitBucket you and your users can use four different rich-text formats (Markdown, Creole, reStructuredText and Textile) to edit issues in bug tracker or pages in wikipedia, while on GitHub you’re limited to use Markdown only.

BitBucket offers source code repositories based on both Git and Mercurial, while GitHub supports only Git (as of writing this).

As mentioned, BitBuckets offers also a set of easy-to-use projects’ importers, for an easy migration from GitHub, Google Code etc. But all of them does not allow you to easily import BitBucket’s repos. So, if you’re sure that you want to use BitBucket, migration will be a very easy task for you. But keep in mind, that this is a one way road, so going back to GitHub, Google Code etc. might be a much harder job.

One, quite big disadvantage

Keep in mind, that GitHub is for their owners the only and most important “child”. A source of their fame and income. So, it does not surprise, that the put all their effort, each and every day, to make it better and better. On the other hand, BitBucket is Atlassian’s orphant child, set as a concurence to their big and expensive products — JIRA (extended bug and issuer reporting and tracking) and Confluence (information and documentation share center plus extended colaboration tools).

No one at Atlassian will ever admit this officially, but you can easily feel, that they treat BitBucket as an oprhant child — limiting number of features, it has, postponing bug fixing and implementation of features as long as it is possible etc., etc. By using BitBucket you agree to have accees to repository management, issue tracker and wikipedia with limited set of features and that you’ll wait even years for implementation of most obvious functions and things.

For example, thing as simple and obvious as labels (tags), that allows you to tag each isssue with certain number of labels, is now “only” fifteen months old and even so, it still has new status. And there are certain reason, why I do fear, that it will never be implmented. Mostly, because of JIRA and some strange design-focus, BitBucket’s dev team has. They kick-back every argument in this discussion, with an answer, that you already have “components”, which work pretty much like labels or tags. The only pity exception is, that you can have only one component per issue, which make them completely useless, at least in the meaning like labels and tags are.

But, let be honest. Even if people are yealling, that they left or are about to leave BitBucket for GitHub or something else, because of lack of such basic functionallity, like labels, BitBucket’s dev and management teams doesn’t actually care much for that. They have their money out of JIRA and Confluence and don’t treat BitBucket to seriously.

Don’t forget about wiki

If you decide to give BitBucket a try, you should also consider migrating your documentation to BitBucket’s wikipedia. It is quite good option:

  1. A person with one account (any of above mentioned) can report bugs or issues and edit documentation,
  2. It is free, on-line, hosted in the cloud, so no software installation / update, no server-work on your side, even no server needed. Much less work for you to setup and handle.
  3. Though it is a wiki / documentation, it is still a Git repository, so you can download entire wikipedia in common format (a bunch of text files in Markdown, Creole, reStructuredText or Textile format) for an easy backup purposes or massive edit / change of files, much faster than online access.

Since BitBucket supports Creole formatting language (quite very similar to original MediaWiki format), it should be a snap of fingers to migrate all your docs with all your formatting, links etc., if you get used to something like MediaWiki.

Please rebase the change locally and upload again for review

You’ve passed all the way of flames, blood and pain, through Gerrit, you done reviewing a change and you’re ready to click Review and Publish button. You hit it and Gerrit hits you with: Project policy requires all submissions to be a fast-forward. Please rebase the change locally and upload again for review. How, the hell this happend and how to handle this?

Read More “Please rebase the change locally and upload again for review”

Setup local FTP server on Windows as quickly as possible

If you ever need to setup a FTP server on your Windows machine, with minimum effort, settings, switches and work, consider using Baby FTP Server. It is really the quickest solution, that I found, for setting up local, one-time use, FTP server.

The only scratch is, that it does not support user accounts and operates on anonymous access only. But, hey! You were asking about quickest solution, right?

Read More “Setup local FTP server on Windows as quickly as possible”