Configure email sending solution under XAMPP

This is the ultimate (at least for me! :]) solution to configuring mail sending in your XAMPP. Verified and confirmed that this is working. If you go through these steps and still have no results, I’m 95% sure, that problem is outside XAMPP or sendmail (i.e. something is wrong with your configuration). I hope, I don’t have to remind you, that every wise guy uses XAMPP only for development purposes and never, ever as stand-alone, production, webserver!

Do not get confused! This article is about fake sendmail, a solution designed for development environments, like XAMPP, to mimic mail delivery subsystem for developers, that is found on production servers. This text has nothing to do with original sendmail, world famous MTA, started 1979 (25 years before fake sendmail!) and still widely used on production servers and anywhere else in hosting area.

Read More “Configure email sending solution under XAMPP”

Round functions in PHP still returns float!

When you round any float number to integer, rounding function (for example floor) still returns float type variable! What?

Well… on second thought, this is reasonable (and explained). PHP does it, because “the value range of float is usually bigger than that of integer“.

So, for example, if you would try to round a number bigger, that integer type can handle (> 2 147 483 647), PHP wouldn’t be able to do anything with the result of such rounding, if it would return it as integer.

Change prompt and enable command auto-completion [updated]

I really like some simple extensions and changes to command line in Linux. An ability to enable command auto-complete, commands history navigation and changing prompts look in particular.

However, not every console is suited with these changes, so I wrote this simple article to keep all my how-tos around Linux command line in one place.

Read More “Change prompt and enable command auto-completion [updated]”

Enable LDAP support in PHP served under XAMPP and Windows

Connection to LDAP in PHP isn’t that easy task by itself. Things get even more complicated, if you’re working in XAMPP environment under Windows. It hope this article will help you in getting un-stuck, if you’re stuck on the similar things, as I did.

Notice: solution provided in this article may not work for you! It worked on my office computer and failed completely on my home computer, though both are quite similar (same version of Windows and XAMPP etc.).

Since, we’re talking about very stupid system (Windows) and about even more stupid situation (claiming, that file is not found, though it exists in folder listed in PATH variable), I have no bloody idea, why it doesn’t work (or why it does work on certain computers) and how to solve this problem.

Read More “Enable LDAP support in PHP served under XAMPP and Windows”

Two-way encryption in PHP

I found two quite interesting examples at Stack Overflow about two-way encrytion / hashing in PHP. While two-way encryption is never as secure as one-way version (some claim, that two-way encryption methods are not secure at all), it is still a good alternative to not using encryption at all. For certain simple tasks, you may find it quite useful.

Read More “Two-way encryption in PHP”

Never allow users to transfer files with non-Latin characters in name

I have received a PM message at Yii forum asking about possibility of transferring (via HTTP upload) files with non-English characters in filename. In this particular example, a Greek and Chinese (and English), but with option to support all the languages, that exists.

Conclusion: No f*ing way! But, if you wish to read something more about this, follow with this article.

Read More “Never allow users to transfer files with non-Latin characters in name”

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”

BitBucket vs. GitHub — VCS and repo management tools compare

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).

Read More “BitBucket vs. GitHub — VCS and repo management tools compare”

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”

Google AdWords ads and Indiegogo crowdfunding campaign

Google AdWords ads uses two URLs: the one, to which ad points to, and the one displayed in ad. These two URLs must follow very strict rules (discussed below) or your ad will be rejected from displaying. Currently Indiegogo uses indiegogo.com domain as main campaigns’ URL and igg.me site to make long URLs short.

For the reasons discussed below, if any Indiegogo campaign’s name is longer than twelve characters, then it’s URL in invalid for Google AdWords and such campaign can’t be marketed using world’s biggest ad network!

Read More “Google AdWords ads and Indiegogo crowdfunding campaign”

Gerrit is wrong. Gerrit is evil!

Gerrit is wrong. Gerrit is evil. Gerrit is the beginning of all hell! If you’re considering using it as version control system, you’re most likely out of your mind! And you’re asking yourself for a big troubles. If you’re forced to use it (like I was), then believe me… your worst nightmares are ahead of you. Nothing, you seen in code review or version control systems up until now, hasn’t prepared you for the pain you’re about to suffer…

Read More “Gerrit is wrong. Gerrit is evil!”

Change could not be merged because of a missing dependency

Gerrit is hard. If you found Git (behind Gerrit) hard to understand and operate, then don’t worry — the real hell is still before you. And one of the biggest Gerrit newbies’ nightmares is situation, when Gerrit is unable to auto-merge particular change, showing “Change could not be merged because of a missing dependency” message. This mostly happens, when you abadon another change, on which current change depends.

Read More “Change could not be merged because of a missing dependency”

Digital Ocean’s introduces AMS2 datacenter

Digital Oceans has officially opened new AMS2 datacenter in Amsterdam. This event forced me to do some small tests on quality of services, from my own (Poland’s perspective) point of view.

I’m not talking about Quality of Service, because this is beyond any discussion. With standard (simple to answer) tickets being answered with 3-5 minutes (!!!) and with more complex cases solved with 3-5 hours, Digital Ocean’s set itself a new world-standard. I have never found or met support of this scale.

So, if we’re not talking about QoS, lets talk about performance.

Read More “Digital Ocean’s introduces AMS2 datacenter”

Push local repo to a new remote with all branches tags and all the history

Since both me and my boss / admin are kind of newbies to Git and since our both vision on how application structure should look is a way different, we quickly did a quite pretty mess in our main repository and got lost a little bit! :] After some short talk, we agreed on one thing (at least). We need to make a new, clean Git repository and push everything from my local repository to it.

This brought us to a question, how to do this? After a short googling, I found these Stack Overflow questions:

but none of them gave me a quick-and-dirty answer (or: checklist) on how to do this, without too much read.

So, I decided to write my own. Once again, Git turned out to be much better and much easier than SVN.

Read More “Push local repo to a new remote with all branches tags and all the history”