Category Archives: Linux

Cutting a video into segments on the command-line

So, today I needed to cut a video into several segments and figured that as in the future I may need to reprocess the best thing to do would be to write a small script on the command-line to do this. Fortunately it turned out to be pretty easy… First create a file called cut_points with the points (in seconds):

(That last line of 100 is some value greater than the length of the video). Then using the following bash one-liner:

Unfortunately this does reencode the video (I guess if you just try doing copy for the a/v streams it will only do it to the nearest B-frame so you’ll only have your cut points accurate to the nearest few seconds which wouldn’t work in my case)

Experimenting with different layout options flexibly using AngularJS

One of the great things about AngularJS is the way you can easily reuse and embed templates and controllers. Recently I was asked to create two versions of a control panel – one where there were several individual pages, and another where we had the pages as tabs. As I was already using the excellent AngularJS Bootstrap plugin I thought about doing something like:

However the issue with this is that you load all the templates (and controllers) at page-load so if I update data in one tab it will still show the old data (from page-load time) when I change to another tab.

After scratching my head for a while I came up with the following simple method:

Then create a simple controller:

And set up the routing (individual pages have their own routes&params already set up):

Job done!

Running processing (and updating the commit) straight after a commit in git

In one project I have a set of templates that I want built into a single file for quicker download. Rather than having to run a command manually after a commit I’d rather this was done at commit-time and then added to the commit bundle. I spent a while figuring out how to do this but basically you need to create a file .git/hooks/post-commit (in every repository – it doesn’t get pushed/pulled) containing the following:

Importing and prepending subversion history to a git repo

So, when I converted some repos from svn to git a few years ago I just threw away the history (I think the git-svn tool wasn’t working or I was in a hurry or something). Anyway, today I was reminded of this and thought I’d backup all my svn repos into git and where possible prepend the history to the repositories. Based on this stackoverflow post and some experimenting I did the following: