Update ImageMagick on Travis-CI

I have an open source software project called Imbo that I have hooked up to Travis-CI for testing of pull requests and pushes on GitHub. I recently came across an issue that made some tests fail on Travis-CI that passed on all other machines I run tests on. The issue seemed to be because of an old version of ImageMagick (6.6.9-7). Travis-CI use this version since they base their VM’s on Ubuntu-12.04-LTS, and that version of ImageMagick is the one currently available on 12.04.

I solved it by compiling my own version of ImageMagick via the .travis.yml file:

before_install:
  - wget http://www.imagemagick.org/download/ImageMagick.tar.gz
  - tar xf ImageMagick.tar.gz
  - cd ImageMagick*
  - ./configure --prefix=/usr
  - make
  - sudo make install
  - cd ..
  - printf "\n" | pecl install imagick-beta

This made the tests pass, but the build went from taking about 2 minutes to 10, so it was not really a good fix. After asking around on the #travis-ci channel on IRC (freenode) @henrikhodne said that they might upgrade the package if they found a decent PPA. I looked around myself and found a PPA for Ubuntu-12.04 that had a newer version of ImageMagick available, so I decided to try and use that instead of compiling my own to see if that might speed up the build. I replaced the above snippet with the following in the .travis.yml file:

before_install:
  - sudo add-apt-repository -y ppa:moti-p/cc
  - sudo apt-get update
  - sudo apt-get -y --reinstall install imagemagick
  - printf "\n" | pecl install imagick-beta

This reduced the build time to around 3 minutes, and all tests are passing! Travis-CI, I LOVE YOU!

Posted in PHP, Technology | Tagged , , , , , , , , | 3 Comments

PHP-based BitTorrent tracker

Some of you might know that I have a library for encoding PHP variables to their BitTorrent counterparts, and back to PHP, called PHP BitTorrent. Some days back I pushed another library to GitHub, namely a standalone BitTorrent tracker.

The tracker is pretty extensible and comes with a couple of back end implementations for you to choose from, the default being MongoDB. The tracker is not a complete tracker system with user authentication and torrent downloads and such, but a standalone “announcer” (like for instance the official BitTorrent tracker: bttrack). PHP BitTorrent Tracker can easily be extended to do user statistics and so forth though. An event listener doing this is shipped with the package.

More information (installation, configuration and more) is available at the project page on GitHub. Feel free to play around with it, and please use the issue tracker at GitHub if you find any issues. Happy torrenting!

Posted in PHP, Technology | Tagged , , , , , , , | Leave a comment

IRC notifications on GitHub

I host my open source projects over at GitHub, and most of them do notifications to IRC on different events. Recently I saw that imbo/imbo and imbo/imboclient-php did not notify new pull requests and new issues in the issue tracker to IRC. These options are not visible in the admin GUI of the hook either. You can however use the API to enable these events.

First, figure out the id of your IRC hook by doing:

curl -u $user https://api.github.com/repos/$account/$repos/hooks

Find the id of the IRC hook, then issue a POST:

curl -u $user -XPOST https://api.github.com/repos/$account/$repos/hooks/$hookId -d '{"events":["push", "pull_request", "issues"]}'

These are currently all the events available for this hook. The hook itself can be found here.

Posted in Technology | Tagged , , , , | 1 Comment

SysInfo-0.1.0 released

The other day I released the first version of a small Open Source (MIT) PHP library that can be used to fetch system information; like for instance CPU usage, load average and memory usage (amongst other information). The library is available at GitHub and can be installed using composer (support for PEAR and phar will be added later).

Installation using composer is very simple:

curl -s http://getcomposer.org/installer | php
php composer.phar create-project christeredvartsen/sysinfo sysinfo 0.1.0

and you are good to go. If you have a project with a composer.json file, simply add a dependency:

{
  "require": {
    "christeredvartsen/sysinfo": "0.1.0"
  }
}

and update your dependencies using composer.phar:

php composer.phar update

After installation, fire up your favorite editor (Vim, right?) and paste the following to get started using the library:

<?php
// Edit to match the directory where you installed SysInfo
require 'sysinfo/vendor/autoload.php';

// Fetch an instance based on the PHP_OS constant. Currently only Linux is supported.
$sysInfo = SysInfo\SysInfo::factory();
// or
$sysInfo = new SysInfo\Linux();

// Get snapshot of CPU
$cpu = $sysInfo->getCPU();

// Get snapshot of load
$load = $sysInfo->getLoad();

// Get snapshot of memory
$memory = $sysInfo->getMemory();

// Get snapshot of disk info
$disk = $sysInfo->getDisk();

// Get snapshot of uptime
$uptime = $sysInfo->getUptime();

The snapshots above are implementations of different interfaces. Read the documentation over at GitHub to see which methods you can call, and what they return:

If you want to add some features or find any bugs, file an issue and I’ll see what I can do.

Posted in PHP | Tagged , , , | Leave a comment

Elastica + elasticsearch

I just published a post on how to query elasticsearch using the Elastica client over at our company blog:

Using Elastica to query elasticsearch

Posted in PHP | Tagged , , | Leave a comment

How to make GitHub host your PEAR channel

GitHub does probably not need an introduction, but their “user pages” might.

Each user on GitHub can have their own pages by creating a repository called <user>.github.com. These pages will be accessible via, yup, you guessed it: http://<user&gt;.github.com. My username is christeredvartsen, so my GitHub pages are located over at christeredvartsen.github.com.

You can read all about these pages over at pages.github.com.

Last year I wrote a post on how to set up your own PEAR channel using Pirum, and now we can use this together with the GitHub pages to have GitHub host our channel.

First, create an empty directory on your machine and initialize a git repository:

mkdir <user>.github.com
cd <user>.github.com
git init

Now you need to add a pirum.xml file in the directory you just created so you can build your channel. The pirum.xml file for my own channel looks like this:

<?xml version="1.0" encoding="UTF-8" ?>
<server>
  <name>pear.starzinger.net</name>
  <summary>Starzinger PEAR channel</summary>
  <alias>stz</alias>
  <url>http://pear.starzinger.net/</url>
</server>

Create the file with your favorite editor and change the values so they fit your own channel, save it, then run the following commands inside your newly created directory:

pirum build .
git add --all
git commit -a -m "Initial build"

Now you can head over to GitHub to create your repository. Once you have done that, enter the following commands in your terminal (in the directory you just created):

git remote add origin git@github.com:<user>/<user>.github.com.git
git push origin master

Now your (empty) channel has been pushed to GitHub, and you can browse it at your user page. Next step is to add some PEAR packages to your channel, re-build, then simply run:

git add --all
git commit -a -m "Added some package"
git push

in the directory where your channel files are located. That’s that, easy as pie!

You can also use a different domain name for your user pages if you want to. Read more about that feature over at GitHub.

Oh, and if you haven’t already you might want to beef up your billing plan from Free to something more awesome. I for one think GitHub is totally worth it.

Posted in PHP, Technology | Tagged , , , , | 1 Comment

PHP_BitTorrent-0.2.0 released

During my Christmas vacation I received a pull request on GitHub for my PHP_BitTorrent project which added proper namespaces to the classes. I decided to merge the pull request and do some other changes as well. I removed the static methods and added instance methods instead which, IMHO, makes the API cleaner, and more important, made the code easier to test.

There are some example usage and instructions on how to install PHP_BitTorrent over at the project page on GitHub.

I have also done some more work on the BitTorrent tracker part of the project which is available in a separate branch (not a part of the 0.2.0 release). Feel free to play around with it and don’t hesitate to send me a pull request if you have improvements for it.

Posted in PHP, Technology | Tagged , , | Leave a comment