en en en en en az en en tr en sv en en en de en en en en ja en en en en en en en en en en en en en en en en en en ja en en en en en en en en en ja en en en en en en en en en en en en en en en en en en en en ja en en en en en en az en en en en en en en en en en en en en en en sv et de en en en en fr en en en en en en en en en az en en en en en en en en en en en en en en en sv et de en en en en fr en en en en en en en en en az en en en en en en en en en en pt en en en en en en en
Recently, I looked at tagging different versions of my project. First, I reviewed the Git manual1 and found the instructions for creating an annotated tag.
git tag -a v0.2 -m 'development version'
Once you have a tag, your list of tags can be reviewed using
Of course, at this point, the tag is still on the local repo. So, to push this tag to the master server, I used the following, where v0.2 is my tag.
Now, when a team member wants to clone or fetch the latest repo, they will get the tag as well. Then, if they need the code from a tagged version, they can check out the tag as follows.2
Git Manual, 2012, accessed  21 April 2014,  .
Stack Overflow, 2012, accessed  21 April 2014,
Getting the Duration of a Video with PHP
If you pass a video to avconv, it returns meta-data about the video, including its duration, e.g.
A search on the Ubuntu forums returned an easy way to parse the above output using Linux scripting1.
$cmd = "avconv -i '$video' 2>&1 | grep 'Duration' | awk '{print $2}' | sed s/,//"; exec($cmd, $result, $error); $duration = $result[0];
Once, I had the above data (e.g.  “00:00:03.76”) in a string, I needed to convert it to an integer value. Further research returned the following snippet of PHP code
list($hours,$mins,$secs) = explode(':',$duration); $seconds = mktime($hours,$mins,$secs) - mktime(0,0,0);
The first mktime returned a timestamp relative to the current time, so we need to subtract the number of seconds from the current timestamp at midnight. This gives us the number of seconds in our video as an integer value.
Raguet Roman, 2012, accessed  21 April 2014,  .
2012, Stack Overflow, accessed  21 April 2014, .
Posted in PHP, Video Encoding, Web DevelopmentTagged Linux, Mint, PHP, Ubuntu, VideoLeave a comment
Splitting a file path in PHP
Posted on Apr 13, 2014 by Denis G Noonan
During the week, I was faced with the problem of dividing a given string containing a file path into the file name, extension and the path to the file’s directory. For example, “/home/myuser/myfile.ext”, has to be split into “/home/myuser/”, “myfile” and “ext”.
My first instinct was to use PHP’s explode() function to split the string on the forward slash. This would give me my file name and extension in the last element of the returned array and each of the directories of my path in the preceding elements. Of course, I would then have to build my directory path from these elements before returning the result, re-inserting the forward slash along the way.
This did not strike me as an elegant way to proceed. So on further reflection, I started my solution using basename(). This returns the file name and extension for a given file path. From here, I used explode to split the base file name into it’s file name and extension. Note that I did not store the “.” between the file name and extension as the specification did not require this.
Now, I needed the directory path to the file. Of course, my input string already had this information. I just had to remove the file name and extension from the end. So, I used substr() to get the sub string from the start of the source path less the length of the base file name (with it’s extension).
This struck me as being a more succinct resolution which is more intuitive to understand. I have included some sample code below.
class PathSplitter { function __construct() { $source = "/home/myuser/myfile.ext"; echo "Source path: {$source}\n\n"; $splitPath = $this->splitPath($source); echo "Split Path:\n"; var_dump($splitPath); } private function splitPath($source) { // Get the file name and extension, i.e. the basename $baseName = basename($source); // Break down the basename into file name and extension $parts = explode(".", $baseName); $name = $parts[0]; $extension = $parts[1]; // The path is the full path name less the basename $path = substr($source, 0, -strlen($baseName)); $splitPath = array( "path" => $path, "name" => $name, "extension" => $extension ); return $splitPath; } }
Posted in PHPTagged file path, PHP, string handlingLeave a comment
Creating a Linux disk image
Posted on Apr 3, 2014 by Denis G Noonan
One of my colleagues needed to set up a server to run the software I was developing. To make his task easier, he suggested that I create a disk image from my development virtual machine.
The most important thing is the configuration would be taken from my Linux environment and so would be guaranteed to run with minimal setup required. As a bonus, he would also get the latest version of my code.
My colleague suggested using Remastersys. This is a tool which can image the Linux environment that it is running on.
Installation of Remastersys was straightforward.
$sudo apt-get update $sudo apt-get install remastersys remastersys-gui
Once installed, I attempted to make a backup of my entire virtual machine.
$sudo remastersys backup custom.iso
It was soon obvious that this was not the best approach. I had a lot of large files from previous work. The disk image failed to create as I ran out of space on my fixed size virtual disk. On failure, the image size was over 11GB, which was way too big for my purpose.
My first reaction was to remove most of the large files.  This time the ISO file was created properly, but again it was large at over 3.4GB. My colleague was at a remote location, and I needed to share the image with him through DropBox. A quick check confirmed that my DropBox account was restricted to 2.5GB of data.
So, I needed a different approach. At this point, I realised that the image did not need most of the files in my home directory, which included a lot of test data as well as development tools. So, I could make a distribution image which excluded my home directory.
In order to accomplish this, I needed to move my project code out of its cloned repository in my home directory and move it to an accessible location for the distribution image. I had to update my Apache virtual hosting configuration and reload Apache. [Please see my last post , Installing Laravel on Linux Mint / Ubuntu/]
Once, this change was made and tested, I removed the Remastersys data related to creating the previous image.
Now, I was ready to create my distribution image.
$sudo remastersys dist custom.iso
Once complete, the new ISO image was 2.4GB in size. While still large, it was manageable. I managed to upload the image to my DropBox account and share it with my colleague, who was able to set up his server with a single clean installation.
Finally, as the disk image was created, I reset my Apache virtual host to point to my cloned source code repository, so that I could continue my development as before.
Posted in Virtual MachinesTagged Linux Disk image CreationLeave a comment
Follow Denis' Technology Blog on WordPress.com
How to Set up a Minikube Lab with VMware Workstation
How to install Elasticsearch on Fedora 28
Versioning in Git using Tags
Getting the Duration of a Video with PHP
Splitting a file path in PHP
Denis G Noonan on How to install Elasticsearch o…
Max on How to install Elasticsearch o…
SutoCom on Installing Laravel on Linux Mi…
Denis G Noonan on Including Autoloader and …
thenewphalls on Including Autoloader and …
How to Set up a Minikube Lab with VMware Workstation
How to install Elasticsearch on Fedora 28
Versioning in Git using Tags
Getting the Duration of a Video with PHP
Splitting a file path in PHP
Denis G Noonan on How to install Elasticsearch o…
Max on How to install Elasticsearch o…
SutoCom on Installing Laravel on Linux Mi…
Denis G Noonan on Including Autoloader and …
thenewphalls on Including Autoloader and …
Follow Denis' Technology Blog on WordPress.com
How to Set up a Minikube Lab with VMware Workstation
How to install Elasticsearch on Fedora 28
Versioning in Git using Tags
Getting the Duration of a Video with PHP
Splitting a file path in PHP
Website Powered by WordPress.com.
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.