About Metric Rat

Facilities Manager by trade, working at an independent school for children with special needs (autism & learning difficulties). Enjoys classic cars (1962 MG Midget owner), running an L322 Range Rover (and also an Audi cab 3.0 and MX5, whilst constantly reparting my daughters Ford Ka) and fiddling with computers (which generally means fixing everyone elses problems with Windows, whilst I sail along happily on Xubuntu Linux :) ). Play guitar, bass and ukelele for fun, and when time allows do a spot of sailing and keep active in the garden. My blog is in essence an echo of my daily trials and tribulations and triumphs :)

Incron gotchas

Of which there are three:

  1. Make life simple and do all your incron as root. I know you shouldn’t but it helps to avoid all sorts of permissions issues. You may need to create an allow file “/etc/incron.allow” and put either root or your sudo name in it.
  2. Ensure that you only have one “SPACE” (not a TAB) between the three elements on an incron job: e.g.

    /etc/samba/smb.conf IN_MODIFY /etc/init.d/samba restart

  3. incron, like cron, requires full paths for just about everything, so if you are calling a script, use the full path to it, and use the full path to all programs inside the script.

Google Sites (Classic) – Embed Live (working) Google Sheet “Range”

This one has been annoying me for a while but I finally arrived at a solution. It is especially usefeul when working inside a G Suite domain, and you wish to share information on a spreadsheet with some selectable cells (e.g. with drop downs) via a classic googlesites page, so for people with the right permissions they can use the functionality of the sheet without causing damage to the underlying data.

The default options and gadgets for presenting a spreadsheet offer too much of the sheet for my liking.

The way to sort this out is to create a web App that can be displayed on the page. The apps script is created on the website (Manage Site > Apps Script), and once the two parts are created inside a project, the app can be deployed and will then show up when added to you page.

So here is what you need to put in your code.gs Continue reading

GAS – Send Event to Calendar from Spreadsheet

Managing a Google Calendar from a spreadsheet is fairly straight-forward.
You do need the calendar ID and all your ducks lined up on the sheet.

in it’s simplest form:

Continue reading

GAS – Send an html Email

Much the same as sending a normal email, but this time you include a body with html tags:

GAS – Get the Last Row

Use this function to get the last row in Column A of a spreadsheet

If you want the first empty row, simply add 1 to ct:

Imagemagick – Tips and Tricks No. 3

Add a Label to a set of images

First bash script coming up, I’ll explain the best I can: I have a set of images that are all square: w=h. I want to create an image of each image with a label on top,using the filename as the label (without the extension), with a white background, ending up with a 200×250 image with the same name as the original but with “-tab” added. IM will by default squeeze the font size so that the text label always fits. Continue reading

Imagemagick – Tips and Tricks No. 2

Montage

The ability to combine a set of images into one image in a variety of ways, essentially replicates the contact sheets of old. Here are a few ways to create a montage. It works best when all the images are the same height and width. IM does not understand page sizes, and will just create a simple image, regardless of the number of images, you can tell IM which images to use though. It also makes sense when testing and creating montages to save the output to a different directory, otherwise your montages will be included in the next iteration! Continue reading

Imagemagick – Tips and Tricks No. 1

Imagemagick (IM) is brilliant! If you want to do something to an image, Imagemagick can do it! Works on Linux and Windows. Can be scripted. Just use Imagemagick for your image manipulation needs.

Advert over. This and subsequent posts will serve as a reference for me, but also to show what imagemagick can do. Other than one liners, there will likely also be some bash scripting. I have also littered these posts with links to the IM documentation for all the features available with each of the actions. Continue reading