Category: Fun Stuff

May 03

Batch resize all your images in a folder

Install imagemagick using your favourite package manager and use mogrify to quickly and easily resize all images contained therein to 1000 pixels wide.

Facebooktwittergoogle_plusredditpinterestlinkedinmail
comment?
Jul 15

Install hevc codec for .mkv video on Linux Mint

Given how complete Linux Mint is out of the box, I’m surprised to have experienced this problem even after installing all extra codecs from the repositories after initial installation.

Upon attempting to play the latest .mkv episode of Silicon Valley, I received the following error in VLC Media Player.

“unable to decode hevc, there’s nothing you can do about this error”

Or words to that effect.  I’d include a screen-shot of the error but I’ve fixed it now, so am sharing the fix with you instead.  I’ll keep it succinct.

sudo apt-add-repository ppa:strukturag/libde265

sudo apt-get update

sudo apt-get install gstreamer0.10-libde265

sudo apt-get install gstreamer1.0-libde265

sudo apt-get install vlc-plugin-libde265

Facebooktwittergoogle_plusredditpinterestlinkedinmail
2 comments
Jun 26

Installing Dropbox on ElementaryOS (Freya)

ElementaryOS is the closest thing to Mac OS-X in terms of consistency and minimalism of it’s desktop environment interface.  Unlike other Linux distro’s it’s released when the developers think it’s ready, rather than a 6 month rolling cycle.  It’ll take a lot to turn my head away from Linux Mint but Elementary has got a lot of things going for it to be quite honest and I’ll leave you to discover them yourself.  I’m only interested in problems, and the first one I ran into was installing Dropbox.  Installing it from the Software Centre doesn’t work.

They way to sort it, is to install git using sudo apt-get install git

Once git is installed, then run the following commands

git clone https://github.com/zant95/elementary-dropbox /tmp/elementary-dropbox
bash /tmp/elementary-dropbox/install.sh

dropbox-inst-elementary

Dropbox will then open, asking for your account username and password, and the Dropbox sync icon will appear in WingPanel.

References:

https://github.com/zant95/elementary-dropbox

Facebooktwittergoogle_plusredditpinterestlinkedinmail
22 comments
Nov 07

Quick surface plots using GNUPlot

GNUPlot is a free and very neat little graphing tool.  Upon installing it and running gnuplot you’ll be presented with a flashing command line prompt gnuplot>_ at which point you’ll be asking yourself “now what?”

gnuplot either plots data using plot or plots 3D surfaces using splot.

In this example, I’ll plot a surface plot (3D splot) of weekday (x), hour (y), number of jobs running (z).

gnuplot likes to be fed its data in text column format, separated with spaces or tabs but not commas e.g.

#day #hour #jobs
1 1 5
1 2 5
1 3 5
1 4 5
1 5 5
1 6 5
1 7 5
1 8 5
1 9 5
1 10 5

To create a surface plot of this data (my sample data used has values for all 24 hours in all 7 days), simply type

splot ‘path_to_data.dat’ to point to your text file containing your columns of numbers.

The results will be something like this.  Good, but not quite there yet.

gnuplot1

 

 

 

 

 

 

 

 

 

 

Some extra commands in the gnuplot command line window will improve the visual representation of the data, giving us the surface plot we’re ultimately after.

set dgrid3d

set grid

set view 50

set style data lines

set contour base

set hidden3d trianglepattern 7

set autoscale

Finally, use the command replot to update the graph.  The results are now much more usable, with contour lines on the base of the 3D graph to further highlight the “hot spots”, i.e. the hours of what day the most jobs are running (in my example).

gnuplot3

 

 

 

 

 

 

 

 

 

 

 

There’s much more fun to be had tweaking GNUPlot but I’ll leave that up to you and your imagination.  It’s worth finally mentioning  that the commands entered into gnuplot can be scripted and saved as a .plt file to compliment your .dat data file.  Then, to plot the surface maps again, you just need to load the script using…

load ‘path_to_script.plt’

Remember, the final line in your script should be

splot ‘path_to_data.dat’

so that the graph is actually generated, with all the options preceeding it.  e.g.

#My GNUPlot surface map script surf-map.plt

set dgrid3d

set grid

set view 50

set style data lines

set contour base

set hidden3d trianglepattern 7

set autoscale

splot ‘data.dat’

How you generate your actual data to be plotted is up to you.  A scheduled task/cron job which collects the data and appends it to the data.dat file is generally run as a separate shell script, e.g.

#!/bin/sh

#Insert newline into data.dat
HOURVAL=`date | awk {‘print $4’} | cut -d: -f1`
DAYVAL=`date | awk {‘print $1’}
RUNNINGGROUPSVAL=`ps -ef | grep savegrp | wc -1`

echo “${HOURVAL} ${DAYVAL} ${RUNNINGGROUPSVAL}” >> ~/data.dat

and the graphs generated at will using gnuplot.

Depending on the shapes generated by the surface map, it’s a nice touch that GNUPlot allows you to left-click on the graph and drag it around in 3 dimensions to achieve the best possible viewing angle, prior to saving the .png file, conveniently colouring the underside of the surface a different colour to the upper, visible side of the surface.

Facebooktwittergoogle_plusredditpinterestlinkedinmail
comment?
Oct 18

Improve Laptop Battery Life

If you’re running ubuntu or xubuntu then you can improve battery life by running the following script.

Read the tweaks carefully as they prompt you for a y/n answer since answering yes to all will render your usb sockets useless when on battery.  You’ll get an icon in the tray that will allow setting of multiple performance modes, namely Conservative, On Demand, Powersave and Performance as well as a list of possible CPU frequencies.

To Install and Enable it…

cd && wget -O .laptop-mode.sh http://goo.gl/7SPJWP

chmod +x .laptop-mode.sh && ./.laptop-mode.sh

To Remove it..

cd && wget -O .laptop-mode-uninstall.sh http://goo.gl/IGVK8e

chmod +x .laptop-mode-uninstall.sh && ./.laptop-mode-uninstall.sh

 

Facebooktwittergoogle_plusredditpinterestlinkedinmail
comment?
Aug 22

Fun Linux Commands

Although it has a reputation for having a steep initial learning curve, in fact Linux / UNIX is great fun to learn and use, and obviously much more is possible with its command line due to the many decades of constant evolution and improvement that have been put into it by the thousands of active developers in the open source community.

This makes it very rewarding to use.

Here are some commands that are purely about fun and serve little to no purpose in the serious workplace.  They can each be installed using apt-get install or yum install depending on whether you’re using a debian or redhat based distribution.

Enjoy.

moo – displays a cow

sl – lists files in a directory like ls but if you get the syntax wrong, a train will drive across your screen

figlet – useful to turn text into big chunky letters

cowsay (and xcowsay) -displays a cow that says whatever you tell it to say as text (or graphic)

oneko – displays a little ASCII cat that chases your mouse around the screen

rev – reverses text

fortune – displays random quotes/nonsense.  Can be used in conjunction with cowsay e.g. fortune -s | cowsay

 

Facebooktwittergoogle_plusredditpinterestlinkedinmail
comment?
Jul 26

Happy SysAdmin day

It’s July 26th, and that means one thing.  it’s SysAdmin Day.  Make sure you show your systems admin some appreciation today.  Or not.  The choice is entirely yours.

http://sysadminday.com/about-sysadmin-day/sysadwhat/

Facebooktwittergoogle_plusredditpinterestlinkedinmail
comment?
Oct 06

Backing up your ageing DVD collection efficiently

This post is basically a follow on from a previous post “Backing up your ageing CD collection efficiently”, so the title is kind of a play on words.

There are two ways to go (or both) when it comes to “backing up” your digital versatile discs, the first is to copy the disc to an .iso image for digital storage.

Being a big fan of efficiency, I am an advocate of command line power (or terminal emulator power if you’re being pedantic).

dd if=/dev/dvd of=~/mydvd.iso

You may need to replace /dev/dvd with /dev/sr0 if your DVDROM drive is USB powered.

You may also need to install libdvdcss2 to read the DVD if it’s encrypted/copy protected.  sudo apt-get install libdvdcss2 should nail that.  If not, google medibuntu and follow the instructions to add the medibuntu repository to your package manager, then install libdvdcss2, amongst other multimedia goodies on offer (such as w32codecs).

So, with your DVD backed up to an ISO file, you’re done.  Well yes, but those ISO files are pretty big at 4GB+, so why not go the extra mile and mount the .iso as a loopback device, then use the wonderfully simple DVDRIP program to re-encode the 4GB video on the mounted .iso file into a less space hungry, compressed video format that weighs in at a mere 700MB?

mkdir ~/myiso

sudo mount -t iso9660 -o loop /path/to/mydvd.iso /home/matt/myiso

If you haven’t already installed dvdrip, then…

sudo apt-get install dvdrip rar

Then run dvdrip and configure it with valid paths where necessary so it can store its files during the rip and re-encoding process.  The paths show as red if they’re invalid and go green when they’re valid.  Type /home/matt/myiso for the DVDROM device (where it says /dev/dvd by default) to rip the video from your mounted .iso file instead of an actual dvdrom device.  dvdrip won’t be able to tell the difference since the kernels loopback module is now presenting the .iso file as a device.

You should now be able to read the table of contents and re-encode the “DVD” into a compressed video format of your choosing, reducing it’s resulting filesize to as low as 700MB before loosing too much in the way of quality provided “2 pass encoding” is checked.  The re-encoding process will take time – how much depends on your CPU.

Above: dvdrip ripping the selected video chapter from a mounted dvd .iso image file

 

Above: dvdrip re-encoding the ripped chapter to a 700Mb xvid (.avi) compressed video format using 2-pass encoding

Facebooktwittergoogle_plusredditpinterestlinkedinmail
comment?
Aug 21

Backing up your ageing CD collection – efficiently.

Our CD’s are getting a bit old now, and if you have a large collection, ripping them to your iTunes collection gets tedious quickly.  The fastest, most efficient way as always, is to use the command line.  The Linux program abcde “A Better CD Encoder” is a fantastic, simple binary for the task.  Like many other Linux packages, it has dependencies.  The following line, is an example of how to rip an Audio CD, and re-encode the wav file to quality 320Kbps mp3 files written to your home directory.

abcde -o mp3:”-b 320″ -a move,clean

The following script, which I’ve called mytunes.sh will handle all dependencies if needed, and run the above command so you don’t have to remember the syntax.  Don’t forget to chmod 777 it to make it executable.

#!/bin/sh

# This script will turn your CD into a bunch of fully tagged mp3 files.  Just pop the CD in, and run ./mytunes.sh

# Software pre-req checks…
if [ ! -f /usr/bin/cdparanoia ]; then
    print “Attempting to retrieve the cdparanoia cd ripping package…”
    sudo apt-get install cdparanoia
fi
if [ ! -f /usr/bin/lame ]; then
    print “Attempting to retreive the lame mp3 encoding package…”
    sudo apt-get install lame
fi
if [ ! -f /usr/bin/abcde ]; then
    print “Attempting to retreive abcde A Better CD Encoder package…”
    sudo apt-get install id3v2 cd-discid abcde
fi

#Yes, you read it right.  One line of actual code to do the meaty bit.
abcde -o mp3:”-b 320″ -a move,clean

# SOFTWARE PRE-REQUISITES (handled by script if non-existent)
# cdparanoia     Takes the wavs off the CD
# lame         mp3 encoder
# abcde     A Better CD Encoder
# cd-discid     Uses the Disc ID to obtain CDDB information for mp3 files.
# id3v2     Command    line id3 tag editor

Facebooktwittergoogle_plusredditpinterestlinkedinmail
comment?
Aug 21

Merging and Splitting avi’s

Everybody loves DIVX/XVID .avi files.  Here’s a couple of useful tips when dealing with them.  You may want to join together two halves or split a large video file into multiple, smaller files for easier handling between storage devices.

 

MERGING AVI FILES

install transcode (sudo apt-get install transcode)

avimerge -o merged.avi -i part1.avi part2.avi

Its as simple as that.

 

SPLITTING AVI FILES

To split a file into two pieces, install mencoder (sudo apt-get install mencoder) and execute the following commands:

mencoder -endpos 01:00:00 -ovc copy -oac copy movie.avi -o first_half.avi

mencoder -ss 01:00:00 -oac copy -ovc copy movie.avi -o second_half.avi

Done!

Facebooktwittergoogle_plusredditpinterestlinkedinmail
comment?
Social Media Auto Publish Powered By : XYZScripts.com