Archive for the ‘

Programming

’ Category

The CArrayDataProvider problem of Yii

Recently I started digging in the YiiFramework. The first things I want to know about the framework were the basics – how the MVC is accomplished, database connections, ready to use component and so on. As the development team is actually the team that was engaged with the Prado framework before, I assumed that Yii will be very similar which actually is not very true. Well I won’t talk now about all the stuff I noticed and I will go straight to one of the first things I got a little irritating.
Read more

Adding a number of random generated unique strings into db

Today I accidentally got to a piece of code I have written long ago and really got surprised from me. I have created a not conventional solution to a interesting problem. Imagine you have to add a bunch of rows into a db table, for example promo codes, that has column holding randomly generated strings. The strings should be unique of course, so we have unique key in the db! So instead of generating the string, checking if it is already in the table and if not -> adding it to the table, I have just written this:

$j = 0;
for($i=0; $i<$count; $i++)
{
	while(true)
	{
		try
		{
			$code = str_makerand();
			$codeID = $this->addItem(
				$this->tableNameCodes,
				array('code'),
				array($code)
			);

			break;
		}
		catch(Exception $e){
			$j++;
			if($j=10) break;
		}
	}
}

YouTube’s policy for inappropriate content and the embed function

Recently I noticed something in the way YouTube manages the videos flagged as inappropriate by some users. You know such videos you want to watch but you must be logged in. This way you accept and confirm you are older than 18 years. On my facebook profile I had a post with such a video – it is embed of the video as you know. And guess what – everyone can play it. It doesn’t matter it you are logged in or not. Here is the example: Read more

Integrating PHPList and CodeIgniter

Hello to all. It was a busy month ,so I haven’t updated this blog for soo loong. Now I give you a small bonus :) . I was busy with a lot of stuff including writing a library for CodeIgniter dealing with PHPList integration. Before implementing it, I googled a lot for a ready to use library on this particular subject. No luck. So I found myself writing it for an hour and think it is pretty good in doing its job, at least for me :) Here is the library Read more

WAMP not working on localhost without active network connection

Until recently I experienced strange problems with my WAMP server. It is not working when my machine is not connected to the internet. That was a piece of mystery for me. Actually the problem is still unknown for me although I fixed it :) My problem was that I had set the WAMP’s option – ‘Put online’. It took me reaaaally long time until I figure that this was causing the problems. It has to do something with the configurations in the httpd.conf but I am still unclear which setting it is enabling/disabling. Found a lot of threads on the internet about this so thought to share it.

Update: I feel stupid but actually the problem was just in FF. I am still a bit confused why changing the setting of WAMP has effect on the way FF is working …

Non-latin characters in the url and ajax problems

These troubles have some history for me. In a month a go I experienced problems with calling ajax scripts with url holding utf8 characters – bulgarian alphabet for example. So I wrote a javascript function which Read more

Happy programmer’s day to all!

Happy programmer’s day to all of us coding all the day and drinking beer. Cheers! Should we count the 128th day of the year for another programmer’s day ? Here in Bulgaria it is not a holiday at all but anyway

+ 1 vote from me!

Fix for wmode bug still existing in FireFox

I had written a post already for the fixed wmode bug in the new version of flash player in FireFox but now I have made almost complete fix for the issue. The issue itself is appearing when you try to use shift+arrows selection shortcut in TextInput field. So Read more

PayPal and its account optional setting

I had played with PayPal’s integration in a few online stores but never got to this stupid situation. For those that are not aware, the ‘Account Optional Setting’ allows the customers of an online store to pay directly, supplying the credit/debit/prepaid card information. This is really really awesome feature, because creating PayPal account is actually not enough to make a payment. Customers must verify their cards through PayPal which is done by moving through some steps including: Read more

Prado and its page state

I had some hard time tracking a bug of mine. The website is powered with the Prado framework latest version. It happened that the bug was a little tricky to be found. I have extended the TPage class and using it as MTPage. There I had a function used by a TDropDownList which is AutoPostBack enabled on changing the selected index – on the function executes $this->Response->reload(). The actual TDropDownList is in the MainLayOut.tpl file because it should be present on each page. But I have forgotten to use the following syntax:
Read more