Every-day Erlang: Quick and effective cache using ETS (Inaka blog)
Hello again! To continue the "Every Day Erlang" series, I'd like to show you how to implement a quick and simple (yet effective) cache using ets, very suitable to wrap your expensive function calls with it. The complete source code is in form of a rebar library application, at github, that you can easily include for fun and/or profit into your own project. Read More »
Erlang Event Driven Applications (Inaka blog)
Events are one of the best tools to have around in your personal toolbox. There's even a special chapter in the OTP design principles about events, and that's because having an Event driven architecture can do marvels for your code Read More »
A plan is not only good for business
As a developer, one of the things that really keeps me motivated is to know where I'm going. This means that the short and medium term objectives are clear (by whoever might be in charge of gathering requirements or making the specs), and in a somewhat detailed way. This makes it possible (again, as a developer) to make your work flow from one day to the other in a more natural way, mentally planning what you want to accomplish "today" in your trip to the office, and plan "tomorrow" as you work your way to the end of the day Read More »
Every-day Erlang: Handling crashes when calling gen_server:start link outside a supervisor (Inaka blog)
This post is about a nifty trick we used when in need of starting a gen_server process with a start_link call, while at the same time, handling any errors gracefully (i.e: avoid propagating a crash to the supervisors). Read More »
Epers, Erlang, and Domain Events when persisting your entities
In the last article, I presented epers, a small project intended to help build erlang applications that need to persist entities to a database. In this new article, I'll describe the built-in domain events available in the framework. Read More »
Link and Monitor differences
link/1 and monitor/2 are 2 different ways of notifying (or know) that a process died. Thing is, these are really very different in nature and these differences are not widely understood by beginners. So let's shed some light on this subject! Read More »
Persisting your entities in erlang
In this article, I'll describe epers, which is a small project I've been working on. It's currently a "small" project, but quite ambitious, and the idea is to try some "new" ideas and concepts in the erlang we do every day. epers stands for "erlang persistence". As the name suggests, it tries to make it easy to use databases in erlang programs, to make it a little more agile, and (humbly) offer a nice adapter for several databases, hiding their implementation details Read More »
Common Test: Code coverage on subdirectories
Sometimes its useful to organice your source files into subdirectories. Thing is, it's not that easy to create html reports for code coverage for them. Let's see why, and a possible solution for this. Read More »
Dealing with a failed configure when building a php extension
If you happen to get stuck when compiling a php pecl extension with a libtool error like Read More »
Erlang Special Processes without behaviours
OTP has (in its design principles), things like behaviours, applications, releases, and supervision trees. If we zoom into the latter, we'll find supervisors, which supervise processes, that can also be supervisors themselves. Read More »
Erlang Websocket Server using Cowboy
Out of curiosity, and because some of my own projects needed it, I decided to go ahead and try writing a websocket server in erlang. After evaluating some of the available options (so I dont have to implement the whole websocket RFC -and their different drafts/versions- myself), I chose the Cowboy framework Read More »
Generate code coverage for EUnit tests in rebar
To configure rebar to generate the code coverage report in html after running the EUnit tests, add to your rebar.config Read More »
Skipping build steps for dependencies in rebar
If you happen to want to clean, compile, run tests, etc in your project but not in your dependencies, try the skips_deps=true, like Read More »
Making your ivr nodes (call) flow with PAGI
The last article was about how to create call flow nodes for asterisk, using pagi and php, to easily create telephony applications. It's now time to add a layer on top of it, and create a complete call flow with several nodes. Read More »
PHP Continuous integration, with Jenkins and Phing
This article is about how to use Phing in your projects, so a continuous integration server (in this case Jenkins -ex Hudson-) can generate the necessary artifacts for your php application (deployment artifacts, documentation, code metrics, etc). I'll try to show why this will make your life easier when developing or auditing code, generating releases and deploying new versions, trace bugs, etc. Read More »
Advanced telephony applications with PHP and PAGI using call flow nodes
In the last article I've talked about how to create telephony applications using nothing else than the standard pagi client. Also, in this article I've shown how to unit test them, by using the mocked client pagi. Now, since version 1.10.0, PAGI comes with a neat feature, which is a small abstraction layer over the pagi client, called "Nodes". Also, the "NodeController" will orchestrate how those nodes interact with each other. Nodes are essentially call flow nodes. Read More »
Unit test your PHP IVR applications with PAGI
Since version 1.9.2, PAGI comes with a mock of a pagi client, suitable to be used in your own unit tests, so you can test your telephony applications, like IVRs. The idea behind the mocked client is to let you test the callflow side of your application, the user interaction and the exact sequence an ivr application should obey. Read More »
Dependency injection with Xml and Yaml in the Ding container
In this past article I've discussed the dependency injection features when using annotations. This time, we'll see how to use the xml and yaml drivers to do the same. In the ding manual you can find extensive examples (almost all with xml and annotations). You are encouraged to take a look at if. This article will reproduce some of the examples there, extending the concepts a little bit Read More »
Aspect Oriented Programming in PHP with Ding
Aspect Oriented Programming (just AOP from now on), is a very powerful tool we can use to implement the infamous cross cutting concerns we have in our applications (auditing, logging, security, etc). In this article, I'll show how we can easily use AOP in a very simple language like PHP, by using the Ding container Read More »
Sniffing in PHP using libpcap: Thank you SWIG!
I've been wanting to try SWIG for a long time, but never got the chance, for one thing or the other. So this weekend I've finally decided to give it a try by trying to create a php extension that access a small C++ wrapper for libpcap, so I can sniff packets directly from PHP. Just for fun (and actually because I couldn't find any active pecl extension to use libpcap, so it might as well be something useful). I've named it "SimplePcap". Read More »
Dispatching and listening for events in the Ding container
Events in the ding container are strings. This is not a great level of abstraction but still provides a powerful tool to work with. Events also have associated data, sent to the listeners as an argument when firing the event. This simple workflow will allow you to extend your system with autonomous components that react to events, totally decoupled from the rest of the code. Read More »
Ding annotations for dependency injection
In the previous article I've shown how to declare your beans. Now it's time to see how to achieve DI (dependency injection), also using annotations. Read More »
Ding bean annotations
Everything shown here using annotations, is also available by using the XML and YAML bean definition providers, so you are free to use any of the 3 drivers (XML, YAML, Annotations) to define your beans and mix them anyway you like or need to Read More »
Hooks into the bean lifecycle in the Ding container
Sometimes it's useful (or needed) to have the container call certain methods right before injecting (or giving away) our beans, and right before destructing it, as a way of setup-teardown or init-shutdown. Ding provides a way to execute code in some of the points Read More »
Ding container: Using the Xml, Yaml, and Annotations drivers
In a previous article I've shown how to download and install the ding container. The article ended with getting a container instance, but didn't show how to actually define and use your beans. So that's what this article is all about. Read More »
PAGI: Quick telephony applications using AGI and PHP
PAGI is a PHP 5.3 client for AGI: Asterisk Gateway Interface. AGI is a very simple protocol, and it has been implemented in a wide variety of languages, allowing to quickly create telephony applications, like IVR's, voicemails, prepaid telephony systems, etc. If you want or need to create this kind of telephony applications using PHP, you will find PAGI very useful Read More »
Getting Started with the PAMI: PHP Asterisk Manager Interface = Easy Asterisk Monitoring
PAMI is a PHP 5.3 client for AMI: Asterisk Manager Interface. Asterisk is one of the hot topics in the IT world due to its broad acceptance and use case scenarios. Read More »
Installing and using the Ding DI Container
Ding is DI (Dependency Injection) container, featuring IoC (Inversion of Control), and AOP ( Aspect Orientend Programming) for PHP 5.3 (actually, it needs >= 5.3.3). It also supports some Event Driven programming too. Read More »
Writing PHP applications with Doctrine2 as ORM and Ding as DI container
This article will show how we can develop software in php with a nifty design and architecture, and very much like other languages like java, using an ORM and an AOP, DI, Events container. Read More »
Creating isolated environments for PHP applications with PEAR dependencies
Many times php applications need some special configuration in their ini files (like extra modules, or any option that can be tweaked) and of course different versions of pear packages (some may use a deprecated package, or a special version that fixes some bug, etc) Read More »
Using DIME with SOAP and PHP
As you may be aware by now, PHP native SOAP implementation does not support DIME transfers (this implies that the one from Zend Framework(tm) does not support them either). Also, the PEAR soap implementation lacks enough documentation to make it work (at least, I couldn´t from the client side. Read More »
Mocking Global Php 5.3 Functions Using Namespaces
Let´s say you´d like to achieve a 100% coverage of your code in your php application (you obsessive geek..). It´s almost certain you´ll need to start mock´ing things around. So far so good.. but sooner or later you will need to deal with the test cases for the code that use global php functions. How can you mock them? Read More »
Generating a cross compiler for freebsd in linux
I manage a Hudson CI Server that runs on a linux system where I work, and one of our projects is written in plain C code that should be able to run on linux and also freebsd 7. Up to now we were using a freebsd (hudson) slave node in order to build the freebsd binaries. Read More »
AMI (Asterisk Manager Interface) Protocol tutorial
The Asterisk Manager Interface (AMI) protocol is a very simple protocol that allows you to communicate and manage your asterisk server, almost completely. It has support to edit/create asterisk configuration files and also manage the calls, clients, agents, dialplan, etc.
You might also be interested in PAMI. An AMI client/framework that allows you to quickly develop ami clients in an oop/event-driven fashion. Read More »
The Asterisk Gateway Protocol: A practical introduction and tutorial to agi applications
The Asterisk Gateway Protocol (AGI from now on) is the protocol used by the Asterisk server as its interface for telephony applications. AGI is just a way that allows you (as a software developer) to easily make telephony applications that asterisk will run someway along the dialplan. Read More »
Making an Asterisk Manager Interface monitor using PHP, PAMI, and Ding (Inversion of control and dependency injection in your php telephony applications)
Here, I'll write about AsterTrace (https://github.com/marcelog/AsterTrace), a simple project that will help you get started using the asterisk manager interface. Read More »
Bami: A Proof of concept asterisk manager interface (AMI) client written in bash
In this article I explained the inners of the AMI protocol, and talked about actions, events, and responses. As a complement of that article I wrote (just for fun) a little shell script Read More »
Una pequeña historia sobre como se viaja en el subte b, apretado y lleno de gente en horario pico hacia el centro
Una mini anecdota/observacion no-tecnica (como para variar un poco.. ), que pueden bypassear tranquilamente :) como todos los dias, afronte la dura realidad de tomar el subte b Read More »
How to setup nginx to work with FastCGI and PHP 5.2 and PHP 5.3
Nginx seems to be the new silver bullet nowadays, so I've decided to give it a try. Of course it is fun to get it up and running and serve static content Read More »
Configuring postfix to forward all email to a smtp gateway
Suppose you want all your web servers to locally send all email (maybe from your contact forms, or whatever) to a real smtp gateway. If you're running postfix as your mta, this is quite easily to achieve. Read More »
Different relays in postfix based on regular expressions
So I had this particular situation where a site sends lots of emails to its registered users, and some of those emails go directly to the Spam folder of hotmail, yahoo, or gmail, for various reasons. This was acceptable for the majority of the emails, but some of them were really important (like password resets, registration confirmations, and the like) so the site hired a payed smtp relay to be used for sending *only* those emails Read More »