Phelio Gnomi

My words from my mind

Back to Yii

I finally solved the problem with the Selenium testing. The problem wasn’t because of the “Failed opening ‘SiteTest: Firefox.php’” at all. It was just a warning message. The real problem is the curl extension in PHP. I thought I already enabled it, but not when the CLI version is not using the same ini file. So, after I enable the curl in the CLI version of the ini file, it works fine.

I’m still wondering though, how do I make the CLI version use the same ini as the web version.

I wish that I’m done with Yii

No offence Yii, but I’m going to move on. First, your lack of examples in your user manual – where the the manual itself is mediocre to start with – is tolerable. But, I started to wonder if people really use you. For a tool like you, you should be proud if people talk a lot about you, especially best if they talks about the problems they are having with you. At least by then, there will be lots of devoted worshipper that are willing to find the solutions for every problem that people talk about.

I just can’t do it any more. I’m stuck here with a problem that nobody (that I can reach) knows. It all started with one very promising book “Agile Web Application Sevelopment with Yii 1.1 and PHP5″ which is really good to start with. But it only take 3 chapters for you to left me bleeding at a corn field near my uncle Jimmy’s house. I’m still bleeding by the way, just so you know. I just can’t figure out how to make the Selenium works without giving me that “Failed opening ‘SiteTest: Firefox.php’”error. I can’t proceed without Selenium, the whole book is about Test-driven approach. And if the testing tools doesn’t work, how to proceed?

There are still plenty of fishes in the sea. Though you are the chosen one and I have to come back to you one day, I think I’ll just forget about you until then.

The Ruby, C++, PHP and C++

I’m taking the Stanford Online Course called the Design and Analysis of Algorithm 1. So far so good, and then the Programming Exercise 4 hit me hard.

First of all, we are allowed to use any programming language. They only want the final result, regardless of how you process them. So, at week 4, we are supposed to read through a file that represent a Graph with thousands of nodes. And we are asked to find the five largest strongly connected components or SCC.

So, I started with Ruby, which is my language of choice for this course. The algorithm that the professor teaches use recursive. So, after finishing the program and running it trough few test cases which seems to work properly, I run it on the actual file (the thousands of nodes graph). It crashed in the first few seconds saying that “stack level Too deep”. Apparently the recursive is too deep for my Ruby to process. I tried to find how to increase the stack level allowed, but it’s either I don’t understand what they are talking about or the solution is for Mac or Linux. I’m working on a Windows 7.

So, I think maybe I should do it on C++. One reason is because it’s fast, and it’s difficult (so I can learn to be a better programmer, not just a guy who get pampered by modern programming language). Then, if you know C++ and also know Ruby or PHP, you can see that C++ is so much different. So much more difficult. PHP pretty much take care of many things behind the screen for you,things like dynamic array or array with random index name (hash in Ruby, associative array in PHP), or passing the array around like tossing pancake from the pan to the plate. They are not that simple in C++. Array is just a pointer with the size. Passing array is complicated, not to mention about multilevel arrays. It doesn’t have hash or associative array.

I have to admit that I’m too pampered by modern (high level) programming language and it’s not the C++ fault, and creating your own function to search an array or to enable dynamic index naming is just too much for me. So, I go back to PHP and try out it’s maximum stack level allowed. First try, it return error on the 100th recursive. But don’t worry, it turned out that it’s just the limitation that X-Debug set. I remove X-Debug and it can run for as deep as your computer memory can supply (which is a lot and a good news).

I immediately converted the Ruby code into PHP code and voilà, it works on the test cases. Working on PHP is like returning home. It feels natural for me as if I’m talking in my mother tongue. However, When I run it on the real graph, I hit a lot of memory limit error. I increase it few times, from 128M to 256M, to 1024M to 2048M. It consumed more than 1GB or RAM to process 5 millions connections of 800 thousand of nodes. And it run forever. And ever. I never get the result back yet. And I’m suspecting an infinite loop, but can’t really find the proof of it. Therefore, I have to conclude that it’s the PHP problem. It’s simply to slow.

So, my only hope is C++ now, which I’m not good at, and I have to build many functions from scratch. Well, probably I can find some library online. But, I don’t know. It feels like I’m forced to speak Spanish when I only know a few words like “la nina come pan” and “el niño bebemos leche”. And I’m literally not sure is it bebemos or beben? Oh, I’m screwed.

Rant: WordPress App on Android

So, I have a challenge blog, where I challenged myself to draw one eye a day and post it there.

I normally use my Android phone (Xperia Mini Pro) to post the picture of the eye to WordPress. Therefore, I have that little WordPress app installed.

Here is the story. One of my pen is dying, the ink is almost gone. So, I’ve decided to draw an eye using it and write a long dramatic story about it. When I am done writing it, and done trying not to drop my tears, I decided to add some more pictures. So here is what I did,

  • I press on the little camera button on the bottom right (inside edit mode).
  • I choose “Select a photo from gallery”
  • Try to find the picture of my pen which I thought I’ve taken few days ago, but couldn’t find.
  • Still in the gallery browser, I saw the camera button on the top right, which I know will lead me to the camera, so I pressed it.
  • Took some pictures of my dying pen.
  • Oops, I can’t remember what I did after that. I try to simulate it but didn’t come out the way it was.
Anyway, the conclusion is, I ended up in the home screen and the story that I’ve written is no where to be found. So, here is my rants:
  • Android offer too many things, which you think you can rely on them but, meh… (i.e : multitasking, read the story above).
  • Android allow maximum customization. But without customization, the phone is a shit.
  • Bugs everywhere. Well, to fix those, you either wait for the updates (which takes forever depend on what brand your phone is), or root it and install custom rom or install some other apps to replace the original shitty and buggy apps (which (most of the apps I’ve tried) will leads to more bugs).
Well, this is it. It’s time to try and rewrite my sad story about my dying pen again.

jQuery: It’s Easy to Create Websites Nowadays

I used to be proud of being a programmer. But now, given that things are a lot easier with jQuery, I feels that I’m not more than a Web Designer. Not to say that web designers are not cool, they are superb in their graphical creativity, which I’m lack of.

Friend: So, what exactly do you do at work?

Me: I create functionality for websites.

Friend: is it hard?

Me: not at all. In fact, I can teach you some cool tricks. You can just put something like $(“#banner”).slideDown(); and the banner will slide down.

But from the other point of view, jQuery has bring me to a much a higher level excitement. From a web developer that only care of back-end processes (that I can be proud of, but nobody really care) to somebody that is willing to improve website experience (that more people will “WOW”).

Guess the Number

Want to challenge my code to guess your number? Feel free to play my new game. Well, of course it’s not a new game, it’s just another duplicated popular game that probably had been played before the existence of Egyptians.

Here is the jsfiddle link. Feel free to modify the codes.

Curve made of lines

I was playing with WebGL the other day and was trying to create some cool and beautiful random triangles after watching the Doodling in Math Class video on youtube. Well, I did create a function to randomly create one triangle. Yes, only one triangle. Not sure how to write the algorithm to make my computer draw triangles as good as the lady in the video did.

And then, I figured out that, WebGL is not a correct term for what I’ve done. Basically, I didn’t actually use WebGL. WebGL is more powerful and support 3D drawing. What I was using was only the native build in HTML5 Canvas 2D library (not sure what it’s really called).

And then, I started to remember what we used to do during math class when I was younger. We draw lines on the edge of the pages and it become a nicely drawn decorative curve. So, using my newly learned drawing skill, I started to draw lines. And here is what I’ve got, a randomly generated, colourful, on the edge curve. Feel free to play around it and hope you enjoy it.

Back to PHPUnit

I have couples of the same PHPUnit Manual tabs on my browser, not because I’m referring to different parts of the lengthy documentation, but because I keep getting the same result from Google search + suggestion from those in PHP chat rooms.

I don’t know what makes it so hard to learn how to use PHPUnit. I can’t even remember what did I do the last time (which is few months ago) I try it out. First is probably the outdated PEAR project that doesn’t seems to be updated any more. Then, the tutorials that I can’t even get to work on my machine. Googling around doesn’t seems to find me what had I done wrong. And probably the installation guide I posted few months ago has already outdated.

Now, I’m stuck with the fact that my PHPUnit folder under the PEAR folder is not the same structure as what other people on the internet has. Got to continue googling for me. Wish me luck!

PHP Unit Testing : Installing PHPUnit in Windows 7

After playing with Ruby on Rails (RoR) for a while, I’m now back to PHP again. Since PHP is the language that I am using in my job, I have to come back anyway. I’m gonna miss RoR nevertheless. But who cares, I don’t need her right now. And she’s got a little too complicated to understand lately. Probably I will give her another chance if I got a RoR job in the future.

But one thing that RoR keep telling me (even after we broke up) is that I need to test my codes. RoR has this build in Testing module that is just awesome and beautifully made. That bring me to the needs of doing some automated testing for PHP too. So now, let’s welcome PHPUnit *crowd  applauding*.

To begin with, I will first need to install PHPUnit on my computer. Since most of the PHP people out there uses Linux, the installation tutorials are mostly in Linux. While I’m using Windows 7, I need to put some crack on googling it. And that brought me to Joshua Doodnauth’s WebLife. The post is about installing PHPUnit in wamp server. So, it’s exactly what I needed since I’m using wamp server too. However, the post is kind of outdated, so it’s only 70% accurate. But it’s still helpful because the only thing outdated is the PEAR installation part. Yes, you need to install PEAR first. So, if you having problem finding the go-pear.bat file, you should read on.

I do another round of googling, and found out that the latest WAMP server doesn’t include the go-pear.bat in the PHP bin. So, you got to get it yourself from PEAR website here. After you got the file, follow the instruction below which I got it from the Wamp Forum.

NOTE: As Samuel has pointed it out on the comment section, if you already has the php bin folder in your environment variable, you can ignore the phrase “C:\wamp\bin\php\php<your php version>\” in step number four, so it become “php go-pear.phar” (without the double quotes).

1> download latest go-pear.phar from pear.php.net
2> save that in directory” C:\wamp\bin\php\php<your php version>”
3> in run type ‘cmd’.
4> in comand prompt type: “C:\wamp\bin\php\php<your php version>\php.exe C:\wamp\bin\php\php<your php version>\go-pear.phar”
5> type in “system” in first option
6> change $prefix by pressing 1 and a file explorer will pop out. and browse to “C:\wamp\bin\php\php<your php version>” and press OK
7> now type 11 and change it to “$prefix\pear.ini”
8> now press enter and installation will begin.
9>enter Y and then press enter when it asks to alter php.ini
10> after installation run this file “C:\wamp\bin\php\php<your php version>\PEAR_ENV.reg”
11> add include_path = “.;c:\wamp\bin\php\php<your php version>\pear” to C:\wamp\bin\apache\Apache<your apache version>\bin\php.ini. Practically below the line ; Windows: “\path1;\path2″

After that, you can continue the instruction from Joshua’s blog after the part where PEAR is installed. Have fun and good luck.

iOS 5 and its Safari

I am not really a Apple Fan, but by owning an iPod Touch, I’m kind of bound to the Apple products. To avoid being dragged deeper to the hole, I try to resist myself from buying any other Apple products like iPad 2 and iMac (which I wish I did). They are simply too expensive for me.

The announcement of iOS 5 makes me excited and want to quickly install it on my iPod Touch. The previous updates are mainly for iPhone and iPad. So, I was quite disappointed. But the iOS 5 seems to have many things for iPod Touch. One of it surely is the Notification Center and it will probably makes me love my iPod Touch even more. There are over 200 new updates as you can see some of them on Apple website.

Beside using it for entertainment, I did build a web app for it. It was a mini website that is optimized for iOS. The web app is quite satisfying except some limitation that the current iOS has. If you have a small container and your content is very long, you will find difficulty in viewing it. Safari on iOS just doesn’t support scrolling very nicely. It will not show you the scroll bar and to scroll it, you will need to use two fingers.

The good news is iOS 5 come with improvement on its Safari too. Apple added more support for the current already available HTML 5 standard. So now, you can scroll the overflowed content with just one finger. That will mean a lot for my tiny web app. There are also support for various date input format that will display various kind of drop down list for date or time which you can read more about them here.

However, it’s still quite disappointing that it will not support file upload yet. Despite of the disappointment, I’m still very excited for its release around August this year.

Follow

Get every new post delivered to your Inbox.