This project started out of researching how to play sound from spotify or rhythmbox from my laptop running ubuntu 11.10 through my hifi. Initially I set out to see if an airport express would work using raop and pulseaudio but it seems that support for the new 802.11 version is flakey so I didn’t wish to invest £80 in a device that might not work. During my research I found that DLNA supported streaming, DLNA is a protocol commonly used for sharing media files with devices such as networked dvd players, internet tvs and consoles like the ps3 so I explored further.
DLNA is supported in Ubuntu (and other modern linux distros) by Rygel, part of the Gnome project. Rygel provides a DLNA server which also has the capability to capture a pulseaudio sink (an input or output stream) and stream it to a DLNA enabled device.
Below are the steps I took to enable me to stream audio from my computer to my Sony BDP-S370, they should be applicable to any similar device: Read more ▼
Developers who work with PHP applications that upload files commonly struggle with providing user feedback on the upload progress, usually using flash and javascript solutions like uploadify. In PHP 5.4 there is now integrated functionality to allow file upload progress to be passed back to the browser.
In this post I’ll describe the basic operation of this feature and describe a quick example of its use.
The upload progress functionality stores the current progress in a session variable which can then be queried as required to give the current progress, it requires the use of PHP native sessions. The $_SESSION key is set by the form name and a prefix defined in php.ini
I’ve been excitedly awaiting some of the new features found in PHP 5.4, in particular array notation and file upload progress monitoring so I decided to try and install PHP 5.4 on Ubuntu. Fortunately there is a repository of prebuilt packages for Ubuntu 11.04 (Natty Narwhal) at http://apt.damz.org/
I recommend using a VM so you don’t mess up any stable PHP install – I only tested this on Ubuntu 11.04 as that’s what was recommended and I already had a VM with it installed.
Installation
Installation is a very simple matter of adding the gpg key:
I’m a regular user of codeigniter-simpletest developed by Eric Barnes however I ran into a number of issues when attempting to run some features under PHP5.3, this was due to using an old version of Simpletest. I have now updated this and had my pull request accepted and merged into the main repo so that it now uses the most recent versions (1.1alpha3).
There is however one important change to note which will stop old tests working, that is the way that test classes define a label, these are optional so this only applies if you use them in your project. The name of the test is now passed through the simpletest constructor otherwise the default is to use the classname of the test.
Before
class test_users_model extends CodeIgniterUnitTestCase
{
public function __construct()
{
parent::__construct();
$this->UnitTestCase('Users Model');
$this->load->model('users/users_model');
}
etc...
After
class test_users_model extends CodeIgniterUnitTestCase
{
public function __construct()
{
parent::__construct('Users Model');
$this->load->model('users/users_model');
}
etc...
This was my first PHPNW conference but after hearing so many good things about the conference in previous years I thought I’d give it a go. In this post I’ll summarise some of my highlights.
Most of my projects at work involve resizing images in PHP applications, usually the result is loaded via AJAX so it needs to be generated as fast as possible for optimum user experience. Recently I discovered the ability to fork processes in PHP, this gives the ability to run multiple functions at the same time. In the example below I’ll demonstrate how parallel processing can be used in PHP to speed the generation of several different sizes of preview images from a large uploaded image.
This code uses the PCNTL extension which was installed as standard on my Ubuntu 11.04 PHP 5.3 install.
This post describes a recent project I completed to display caller id information for incoming calls on my computers. The project uses a BT Caller Display 50 connected via an optoisolating bridge to an arduino with an ethernet shield. When an incoming call is received the telephone number is transmitted via MQTT to a python client on any computer I happen to be using at the time. This project is a great example of someone putting great effort into being lazy, the caller id data is alredy displayed on my phone but the phone generally resides in the next room so this avoids me needing to run for stupid cold callers. Initially I’d wanted to do this project just using the arduino, which may have been possible but using the CD50 makes it a huge amount easier.
Creating sitemaps is a bit of a hassle for any site bigger than a couple of pages, especially where a database is involved. While working on a recent project I created a library for codeigniter which allows the simple creation of sitemaps either by manually adding pages which might be appropriate for a blog, or allowing the library to scan controllers and adding all pages defined by methods. Common search engines can also be notified.
A simple example of it in use is shown below:
//if you're using sparks
$this->load->spark('codeigniter-sitemaps/0.0.1')
$this->load->library('sitemaps');
//assuming a hypothetical posts_model
$posts = $this->posts_model->get_posts();
foreach ($posts AS $post)
{
$item = array(
"loc" => site_url("blog/" . $post->slug),
"lastmod" => date("c", strtotime($post->last_modified)),
"changefreq" => "hourly",
"priority" => "0.8"
);
$this->sitemaps->add_item($item);
}
// file name may change due to compression
$file_name = $this->sitemaps->build("sitemap_blog.xml");
$reponses = $this->sitemaps->ping(site_url($file_name));
When prototyping circuits I often use a breadboard and an FTDI cable which usually leaves some kind of hacky looking unstable connection using wires stuck into the FTDI cable female header connector. This arrangement often leads to failiure as the wires fall out. After much searching I’ve managed to locate a solution to allow neat connection of a female header to the breadboard.
Recently I’ve been experimenting with using webcams in the browser with Javascript, while I was browsing Google on related topics I came across an interesting video on youtube. As I couldn’t find any code for how the demo had been created I decided to create my own (see below). The idea of streaming video from a phone to a server via a websocket had occurred to me before I viewed this video but I dismissed it as impractical, an opinion which has only been reinforced after testing it myself.
This is the video that gave me the inspiration (my code replicates this exactly so I didn’t see the need to recreate the video too), the only difference is I used linux all round rather than windows: