Athens to Altanta train recurring dream

tl;dr  personal note, just skip reading it.

I’ve had several dreams (throughout the years) that have something to do with a train that goes from Athens to Atlanta. It would be fun if some day I could take such a train just to say “I’ve dreamed this before”.

There’s some planning about building such a commuter train though.


It is unlikely that we will see any extra-terrestial intelligent life

tl;dr  Given the size of the universe, and statistics, it is extremely unlikely that we will see any extra-terrestrial intelligent life.

It was very unlikely that a child would get to a Gorilla in a Zoo (the story has been covered in many places such as this). We all make mistakes once in a while. Rarely though, a combination of unfortunate events or mistakes happen. In this case it was:

  • A parent did not keep an eye on their child for a minute or two.
  • The child made it into the gorilla area.
  • The design of the zoo was not 100% perfect for blocking access to the gorilla by visitors.

Not too long ago, I made a very minor mistake that was due to my lack of judgement. No one was harmed at all, no one even noticed, it did not affect any one or anything. It was fixable (with either 20 minutes of time, or $30 payment). My error was statistically unlikely. It was from the combination of two events: lack of judgement. The second event is something that I do at most once every two weeks. The probability of two independents events is usually calculated by multiplying the probabilities of each event. For example, if one event has a probability of 10%, and the other event has a probability of 5%, then the probability of both events happening is 10% times 5%, which is equal to half of a percent.

Hence, the probability of the Gorilla and child event, should be really small. This can be somewhat seen by the many years in which such an event has not happened before. (Remember that many many people with kids go to the zoo all the time).

Now, is it likely that there is intelligent life in different planets than ours? yes, of course. However, when we consider how big the universe is, it is extremely unlikely that we will see any extra-terrestrial intelligent life. Just think about how long it took for a satellite to get anywhere near Pluto to take photos of it at a good enough resolution so that scientist can figure out things about it. Or, think about the distances required and the speeds needed to get there alive. For example, even though I can see the moon, it takes an gigantic amount of energy and effort to get a human there. It has been decades since I last heard of fast-speed trains that could do a 300 miles trip in 40 minutes. Considering that we do not have a network of such trains to help us move faster between cities, what is the likelihood that we will organize things to go to other planets? If such delay happens here, it is likely to happen in other planets having intelligent life. Hence, they will not be showing up any time soon either. (They are probably on the sofa watching their version of popular TV shows or something like that).

Thus, no extra-terrestrial intelligent life showing up on our skies any time soon.

Mock testing in Zend with Doctrine: mimicking the mocking

A few notes about mock testing in Zend with Doctrine.

There is great material already about this topic (such as this, this, and this).

  • The goal is mocking the retrieval of the entity manager to avoid making a mess with the existing database.

“unable to create an instance for doctrine.entity_manager.orm_default”

The Bootstrap.php may be a place to fix the error “unable to create an instance for doctrine.entity_manager.orm_default” via adding the following line. It seems to “force” the service manager to initialize the instance.


However, a nice solution was to create the service via a constructor that receives both the service manger, and the entity manager. The service is not created in the controller. Instead, it should be placed in the Module.php file for the module. The service will then almost-never need to be created via ‘new’. This is how it looks like in Module.php:

public function getServiceConfig()
   return array(
      'factories' => array(
         'BagelService' =>  function($sm)
            $em = $sm->get('doctrine.entitymanager.orm_default');
            return new BagelService($sm, $em);

This facilitates mocking the entity manager. However, I did not follow that route.

Minor note: in our setup there is something not 100% perfect, which requires me to utilize ‘doctrine.entitymanager.orm_default’, which does not have an underscore between the words entity and manager.

My setup was to initialize the service passing only the service manager to its constructor. It is normally initialized inside of a controller. There is nothing about the service in the Module.php file.

Example of test setup and actual test.

Initialization in the setUp function is done through the Bootstrap class.

protected function setUp()
   $this->serviceManager = Bootstrap::getServiceManager();
   $this->bagelService = new BagelService($this->serviceManager);

Example test:

public function testBagelPromotion()
   $response = $this->bagelService->getPromotion();
   $this->assertEquals('Buy 1 bagel, get free coffee', $response);

In some tests, I’ve grouped several asserts together using an array as follows:

public function testObjectInitiallyEmptyValues()
    $fields = ['Items', 'Payments', 'Attachments'];
    $obj = new EntityABCDEF();
    foreach($fields as $each) {
        $this->assertCount(0, $obj->{'get' . $each }(),
           "'$each' should initially have zero elements.");

Example test mocking the entity manager:

public function testGetBagelById()
   // Create a dummy object
   $object = new BagelEntity();

   // Mock the entity manager
   $emMock = $this->getMock('EntityManager',
      ['getRepository', 'getClassMetadata', 'persist', 'flush', 'find'], [], '', false);

   // Create a mocked service, only mocking one method
   $mockedService = $this->getMockBuilder(BagelService::class)

   // setup the expectation of the method we are mocking

   // 'find' should return our dummy object
   $emMock->expects( $this->any() )

   // Call the mocked service requesting an object
   $response = $mockedService->getBagelById( 12 );

   // Check the response is the correct type of entity
   $this->assertInstanceOf(BagelEntity::class, $response);

   // Check that the returned entity is our dummy object
   $this->assertEquals('BAM12345', $response->getBagelNote());

There were tests where I did not utilize the mock entity manager because the functionality being tested did not require it. Examples: testing that requesting an entity by ID with an invalid ID returns null, and testing that QueryBuilder was generating a query correctly.

Why was all of this helpful?

  • I found out that we have functions that are repeated in other classes. My suggestion to the team lead (when she comes back from vacation) will be to have such functions moved to a Utility class.
  • I had to move some strings constants as actual defined constants in order to test the output of a few methods to avoid having the test-case break in case that our customer wants us to change something such as a description of an error message.

Can I join your party?

tl;dr  subtle flirt by female approximately 10 years older than me.

“Can I join your party?” she said as a subtle flirt, or just joking. She was likely 10 years older than me. Maybe just 5 years older. In all fairness, it is very likely that I *think* that I look much younger than I actually am. That’s what you get when you are in a University setting, with so many people that fit the definition of “young”. She was kind of a hippie looking though. Long are the days since I bother to look at people hand’s to see if there’s a wedding ring.

The small group that I joined was seated on a table already. We moved to a bigger table after two more of us arrived. While moving, I was able to see that she was seated in the bar. She had mentioned to the waiter that she was joining some friends. One hour later and she was still there. I also say that “I’m with friends” sometimes, when in reality I’m just with friends via my small electronic device.

A guy finishing his Mickey Mouse PhD

One of the *perks* of working at a University is to attend seminars every now and then. However, at a recent seminar, the speaker referred to previous research in a not very nice manner. The presenter used this phrase to emphasize that the research was not great: “A guy finishing his Mickey Mouse PhD”. My question is: Is it really necessary to say it that way? I would rather just hear that the previous research is not solid.

I’m pretty sure that you could pick any random Professor at a research-university and find some hole in their research because doing everything perfectly is near impossible. But that does not mean that we should carry on and insult people. In particular, when the person being criticized died decades ago!

Data Structures COSC2320 is not an easy grade

I am a temporary part-time, instructor faculty in the Department of Computer Science at the University of Houston (Spring 2016). I will not teach on the summer session. I will teach on Fall semester (exactly the same course).

On Spring 2016, slightly over 25% of students dropped the class before the deadline for withdrawal with “w“. The programming assignments (homework) require substantial time investment. There are at least 10 days between each homework. The class webpage is now hosted in git: uhcs2320.

On Fall 2016, the same course is available with a professor that has several more years experience in teaching it than me. Reviews on her course likely are available in the usual places. Also on Fall 2016: there is a *new* version of the class (4 credit hours instead of 3) that has a required lab session with it. The professor teaching it also has several more years experience in teaching it than me. Similarly, reviews on his course likely are available in the usual places. My course is much more similar to his course.