Getting Started With Love2D Basics

I recently started playing around with Love2D for game development. Although I am completely new to Lua, so far it's been pretty fun and I really like it.

I created this post to write down the most important basic concepts that I have encountered so far, so that I can use as quick reference later.

Setting Up a Basic IDE

So far I've been using Love2D in Windows. Initially I started using Sublime Text 2 as my editor, but then figured out how to make my Love2D development experience much better using Atom combined with Github for Windows.

In Atom there is a great package called love-ide which has many great tools and features for developming with Love.

Love Atom IDE

Some of these features include Lua linting, autocomplete, and being able to run the Love application right from Atom.

Working With Keyboard Keys

We can interact with user input through the keyboard by determining if a certain key has been pressed. This is done like this:

if love.keyboard.isDown("right") then
  -- ...

The love.keyboard.isDown function receives a KeyConstant string argument to indicate which key we want to test for. The complete list can be found here. Here are some examples:

Key string Description
space Space key
backspace Backspace key
down Down arrow key

Read more…

Extending Device Python Classes From Other ZenPacks

Recently I was struggling with trying to make two custom ZenPacks work together with device objects in the Zenoss database. My issue was that a main ZenPack (which would be installed first) would create a custom class that inherits from Device. This ZenPack would add a lot of properties and relationships with custom components. Then, a second optional ZenPack could be installed which would extend this same class with an additional property that would work along with a Python data source.

The zenpack.yaml file for the first and main ZenPack would look something like this:

# ZenPack1

    base: [zenpacklib.Device]
    label: Special Server

    base: [zenpacklib.Component]
    label: Special Component
      # ...

    base: [zenpacklib.Component]
    label: Amazing Component
      # ...

  - SpecialServer 1:MC SpecialComponent
  - SpecialServer 1:MC AmazingComponent

Read more…

Using Lambdas in Case Statements in Ruby

In a previous post I talked about how we could use Ruby ranges inside case statements. This was a very neat way of using case statements that would make our code more readable and less repetitive.

The other day I was trying to solve the Bob Ruby exercise in Exercism, and I came up with another very cool way to use case statements: with Lambdas.

The Problem

The Bob problem is very simple. The program receives some input, and it returns some output based on the contents of the input. A strong indication for using a case statement. From the problem's README file:

Bob is a lackadaisical teenager. In conversation, his responses are very limited.

Bob answers 'Sure.' if you ask him a question.

He answers 'Whoa, chill out!' if you yell at him.

He says 'Fine. Be that way!' if you address him without actually saying anything.

He answers 'Whatever.' to anything else.


The test provided by Exercism indicates that we should create a Bob class with a hey class method that receives a remark. We could then use a case statement with this remark and evaluate if the remark is a question, yelling, or whatever else needs to be determined according to the instructions. We could create some class methods to determine each of these possibilities:

Read more…

Zenoss Custom Notification Actions Using Subscribers

In a previous post I talked about how we could create custom notifications actions in Zenoss. Like a SMS notification, for example. In that post we required a valid cellphone number using a text field in the notification's content pane, as shown below:

Notification Content

In this post I want to change and improve this by using subscribers functionality instead. Similar to the e-mail (or pager) notification, which sends an e-mail to all the subscribed users using their e-mail address configured in their user settings. Since there is no SMS mobile number that we can configure in the user settings, we will have to use the Pager field instead.

The Pager Action

Using Zenoss Core 4's pager action's source code as reference is a good starting point, since we are going to use the pager field for SMS.

We can see that this action class implements a executeOnTarget method instead of a execute method we used in the previous post.

Read more…

Python Functional HTTP Testing With Gabbi

Continuing with my journey in contributing to Gnocchi, I have learned of an excellent tool which Gnocchi uses to test its API from a HTTP request approach. The tool is called Gabbi.

Coming from a Ruby, Rails, and Rspec background, I was very pleased on learning how Gabbi works and how to use it. Gabbi uses YAML to construct the tests that will hit the API endpoints, in a similar way to using Rspec's DSL when making request specs.

For my latest contribution to Gnocchi, I was working on an issue where newly created metrics were not being returned in the response from /v1/resource/generic/:id/metric. After applying the fixes and submitting the patch, it was also necessary to update some of the functional Gabbi tests that belong to this specific use case.

One of these original tests is shown below:

Read more…