Ready Player One – book review

Ready_Player_One_cover

Spoiler alert! I may spoil something you don’t wanna know, keep reading at your own risk.

I’ve finished reading Ready Player One a few days ago, and I feel this book is… “strange”.

On the one hand I think it’s a really good book, I read it in a few hours in 2 or 3 days. Every time it was very difficult to stop reading it and wait for the next reading session!

On the other hand I feel that the conclusion of the story isn’t well connected with the rest. It seems it’s ending because it has to and not because it reaches a real end.

The whole book is a complex web of connections, discoveries, relations and mysteries. But I felt that the end was too simple, there wasn’t the same atmosphere the rest of the book has.

My suggestion is: read it because it’s a good book, but do not expect much of the end 😉

 

Installing nodejs and npm without root privilegies

nodejs_log

npm_logo

Yesterday I released a short bash script to help with installing nodejs and npm from source without having to do it as a root user: nodeinstall.

My script is just an automation of the instructions that you can find in this blog post from Tom Novelli.

The idea is that having to use the root user permission to install nodejs packages can be a security risk. Moreover it’s a pain to insert your root password every time you install a nodejs package as global 🙂

Pull requests and any other feedback are welcome!

P.S.: if you are looking for something way more powerful and complete than my script you can check out NVM 😉

PHP PayPal REST API Client

mark_paypal_111x69

Today I have published a PHP client for the PayPal REST API. There was an official SDK already, so why another library?

These are the reasons why I have decided to work on a new client:

  1. Using the official SDK felt a bit awkward: a lot of setters, a lot of static methods and a lot of coupling between classes.
  2. I tried to contribute to the official SDK and I failed: I gave myself a week (after work hours) to get a better understanding of the SDK, and to come up with a PR to make the SDK tests run without calling the actual paypal sandbox endpoints. At the end of 6/7 hours of work, I didn’t submit a PR: it would have broken a lot of interfaces and there were still tests calling the sandbox endpoints.
  3. No way of mocking the class making the calls: I was using the official SDK on a side project, and it was not possible to mock only the class that made the real calls – because it was always instantiated with a “new”. I had to implement a class that contained all the logic for using the SDK and mock that.
  4. I didn’t need to call all the endpoints: I only needed to get direct payment working with “paypal” payment method.

So these are the reasons why I delved into the PayPal REST API reference. I played around to make calls and see if I could come up with an OO library that did only what I needed.

Whit PHP PayPal REST API Client you can:

To start using the library just add the following line to your composer.json

"p16/paypal-rest-api-client": "0.1.1"

and then run

composer update p16/paypal-rest-api-client

Giving back to the community much less than what I’ve taken!

Feedback, PR and suggestions are more than welcome!

Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for …

zf-logo-mark

Maybe this is a silly error but still it took me more then 10 minutes to figure it out.

If you are:

  1. using Zend Framework 2
  2. you use the abstract factories to declare how your services should be built
  3. and you get an exception that states “Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for […]”

chances are you are missing a little bit of configuration in your factory.

In my case I was missing the name of the service I wantend to use in the $validNames array, at the beginning of the AbstractFactory.

use Zend\ServiceManager\AbstractFactoryInterface;

class MyAbstractFactory implements AbstractFactoryInterface
{
    protected $validNames = array(
        'servicename1',
        /* 'servicename2' is missing! */
    );

    public function createServiceWithName(ServiceLocatorInterface $sm, $name, $requestedName)
    {
        switch ($requestedName) {
            case 'servicename1':

                return ...;

            case 'servicename2':

            return ...
        }
    }
}

Hope it helps!