When Plex announced that it would be an official Chromecast partner, I knew that I had to get ahold of one. On Christmas day, I jumped onto Amazon and ordered one for £35.
I had been using Plex for about 4 month before this, however I only had access to a very limited set of features due to using it as a DLNA device. I could browse the media (thumbnail and title) and play, and that was about it.
Getting the Chromecast has unlocked a lot more features that have made watching TV shows and Movies a whole lot nicer.
For example, I use trakt.tv extensivly, and with a simple plugin, Plex automatically sends what I am watching to Trakt. This means I can keep track of what I am watching, and even tell Plex to filter only "Unwatched" episodes/movies. This now works with stuff I watch on my TV thanks to their Chromecast support, so I no longer have to worry about marking things as watched manually with an app.
Another great advantage is being able to control your TV with basically any device in the house. I can pick my Mac up, choose a TV show and start watching, and then pick my phone up and turn the volume down on the TV. This makes everything seamless and much nicer to use.
Because it's all going though Plex, it also means that I could stop watching something half way through, and pick up where I left off on my phone. For example, I could watch QI on the way home on the Metro, and finish watching an episode on my TV using Chromecast when I got in.
If you use Plex, and have not yet got a Chromecast, then I really recommmend it. It has made watching media a lot nicer experience overall. And if you do not use Plex, then try it out!
Let me know how you get on in the comments.
About 2 month ago, I found a nice service going by the name of pushover.net.
"Pushover makes it easy to send real-time notifications to your Android and iOS devices."
I had a look around for a decent PHP library, but could not find one. Most of them either had way too much code for such a simple task (it's basically a curl call), or where totally untested.
The library I built is very easy to use, and easy to setup. Below you can see an example of how to send a push notification:
2 include __DIR__ . '/vendor/autoload.php';
4 $pushover = new \Scottymeuk\Pushover\Client([
5 'token' => '',
7 $pushover->message = 'testing';
9 // Push Single
10 $push = $pushover->push($token);
12 // Push Multiple
13 $push = $pushover->pushMultiple([
The only downside to pushover.net is that the app costs, but with the amount of things I use it for, its been worth it.
If you wish to try out the library, then you can view it on Github.
Can't think of a use case? I built a quick CLI tool using the library to make it easy to push things to your mobile from your desktop. You can view that on Github too.
If you do happen to use any of these, please let me know in the comments below.
While reinstalling my Mac today I realised how easy it was to get PHP and Nginx working with Supervisor. However, if you asked me this the first time i setup my Mac, I probably would have screamed at you for not helping me.
Supervisor allows you to manage any process with ease, and through a simple web ui. You can manage anything from PHP itself, to long running scripts. We use it on romhut.com to manage the upload workers which are written in PHP, its very powerful to use, once you know.
I figured I'd write a blog post to explain how simple it is, and act as a copy and paste reference for me in the future.
I am going to assume you have the following installing:
- PHP (with "--with-fpm" option)
First we need to install Supervisord, to do this we need to install "pip". You can do this by running the following commands:
This will then allow you to run:
sudo pip install supervisor
We can now create our supervisord.conf file, which will tell Supervisor how and what to run. I created mine in /usr/local/etc/supervisord.conf. Note that you can create it in a few different locations and Supervisord will automatically pick it up, have a look at their docs for this.
The following is my supervisord.conf file, which includes configs to run the web interface:
port = 127.0.0.1:9001
logfile = /var/log/supervisord.log
logfile_maxbytes = 50MB
logfile_backups = 5
loglevel = info
pidfile = /tmp/supervisord.pid
nodaemon = false
minfds = 1024
minprocs = 200
user = root
directory = /tmp
strip_ansi = true
; RPC Interface
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
serverurl = http://127.0.0.1:9001
files = /usr/local/etc/supervisor.d/*.conf
If you notice on the last line, we are including files from /usr/local/etc/supervisor.d. This means we can place config files for PHP, Nginx etc in this folder to keep it cleaner, however you can place all the configs in the above file if you so with.
First off, we will create the config file for php-fpm in /usr/local/etc/supervisor.d/php.conf:
command = /usr/local/sbin/php-fpm
user = root
autostart = true
The above will run php on startup as root.
Next we will add the Nginx config file in its respective file:
command = /usr/local/bin/nginx
user = root
autostart = true
This will also run nginx on startup as root. You will also want to add the following to your main nginx config file:
This will stop nginx from daemonizing it's self, and is needed for nginx to run smoothly.
Run the following command to tell Supervisor to look for config file changes. Please note that you will need to run this every time you make a change to the config files.
That should be it all setup ready for you to get these processes running. Simply type the following to test this out:
supervisorctl start php;
supervisorctl start nginx;
PHP and Nginx should now be running, to check this simply run. You should see "RUNNING":
To get Supervisord to start when your Mac starts, you will want to use launchctl. Simply put the following inside /Library/LaunchDaemons/com.agendaless.supervisord.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
launchctl load /Library/LaunchDaemons/com.agendaless.supervisord.plist
At this stage, Supervisord should be running and ready to use, however I do normally have to restart my Mac for things to work properly. This could have been due to launchctl having not been used before this.
To check that it is running, simply go to http://127.0.0.1:9001 in your browser, or use the following command:
If all works well, you should see the following in your browser:
If you have any questions, or suggestions please let me know in the comments below, or tweet me
Over the past few months I have been searching for a backup solution for my VPS's. I wanted a single solution that allowed me to backup multiple sources such as MongoDB, MySQL and the usual files.
After a while searching, I decided I would build it myself, due to not being able to find the perfect solution.
Before this, I simply had the Dropbox service running on each machine, and had a cron that copied mysqldump into the Dropbox folder, which was synced. This worked well, but it was quite laborious to setup.
Because of this, I opted to use the Dropbox API directly to backup from the tool. This allowed me to deploy the script to any server (see here) and the only dependencies are PHP and Curl.
When setting it up, all you need to do is run:
This will give you an authorisation link for Dropbox, which will return a token which is used to build your config file.
Once you have set the config file up (see the repo's README.md for details). You will be able to simply setup a cron to run the following for instance:
This will loop over each database you have access to, mysqldump them, gzip them and upload them to Dropbox. My MySQL (and MongoDB) backups, are set to backup once per hour, but the file is stored YMD, which means that the file will be overwritten. This would normally be a bad thing since you could overwrite with a bad backup easily, but because we are using Dropbox, it keeps internal revisions meaning that we have around 23 copied per day, but we keep the storage space to a minimum.
If you would like to view the source, and maybe use the tool, then please head over to Github. Let me know if you have any questions, or suggestions.
For the past year or so I have been using rsync to deploy my sites, which has worked perfect for me until recently.
I have recently switched to using a simple post-receive hook using a bare repo on the server. I find this works a lot better for me now as it means all I need to do is "push".
First you need to setup the repo on your server, I normally set it up in /var/git/site.com for example. This will be a bare git repo, so it will not contain any of your own code. To set this up simply run the following inside your /var/git/site.com folder:
This will initialize the repository, allowing you to push your code to it.
The next step is to tell git where to check your code out too. I usually use /var/www/site.com. For this, I use a very simple post-receive hook that checks the code out to the folder, and runs composer install. You would place the following in /var/git/site.com/hooks/post-receive:
GIT_WORK_TREE=$WORKING_DIR git checkout -f;
cd $WORKING_DIR && composer install -o;
One thing to remember is to make the file executable by running the the following command:
chmod +x /var/git/site.com/hooks/post-receive
Now that the repo and post receive hooks are setup, we need to setup your development machine's git remotes. The easiest way to do this is:
git remote add production email@example.com:/var/git/site.com
This will mean that you can simply run the following command to deploy your website:
git push production master
You can obviously add anything else you wish to the post-receive hook, such as clearing cache, flushing cdn etc. I currently have most of mine set to restart php-fpm after composer install.
If you have any questions, or i have missed anything, then please let me know below.