Code

How to get Weather on the Mac Console

Here is a simple way to get the weather from the console.

For this we need a very simple shell script:

If you don’t pass a parameter, it uses LocateMe which you’d have to download separately. LocateMe makes available the current location of the computer on the command line.

By mnott on 2016/07/29 | Code, Computer, General | A comment?

Perl’s for Kids (and Regular Expressions, too)

We’ve just finished a field study looking at the ability of less than two-year olds starting to learn Perl and Regular Expressions. To avoid any gender bias, we have focused on the female population. From a statistical point of view, we have been able to get 100 % participation of our dataset, which means we have a very clear proof that Perl and RegEx are for Kids. So, if you didn’t look at those, or procrastinated rather than learning Perl, what are you waiting for?

Here are some pics from our study…

By mnott on 2014/03/10 | Code, Private | 1 comment

Visual Feedback from Apple Scripts

I am probably overly abusing Better Touch Tool. As an example, while reading a book in Full Screen mode with Skim, I want to create different types of annotations but I do not want to use the menu or even the keyboard to switch annotation types. I want to keep my hand on the trackpad and do what’s needed – including saving. The issue I saw is that when using gestures, I’m not quite sure whether they actually were executed. Adding today the “save” operation, I definitely needed a simple way to display a notification on whether the given action has been performed. Enter Growl. And a very simple Apple Script that displays, using Growl, what ever has been passed on the command line. The script is given below; here’s how it works.

Read more…

By mnott on 2014/02/10 | Code, Hacks, Research | A comment?

How to paste a URL from the Clipboard to BibDesk as a LaTeX (and Harvard) compatible reference

Now after I’ve ended up about 700 times to always do the same thing: In BibDesk, add a “Note” field to a publication, copy my template for that note field, paste it into the publication, then copy and paste the URL I want to refer to into the right place, I got bored. Here’s another way of doing it (obviously attached to a keyboard shortcut by one of the usual means, e.g. BetterTouchTool). It takes the URL on the clipboard, escapes some characters that LaTeX would choke on, wraps it with my template, calculates the current date, and adds it to the notes field (which is created if it wasn’t there). If the field was there, nothing is added, but the result is copied back to the clipboard. Read more…

By mnott on 2014/01/21 | Code, Computer, Research, Science | A comment?

How to open Preview or Skim from DEVONThink

Unfortunately, DEVONThink utilizes its own PDF preview application. If you’d rather want to open Preview, you can utilize BetterTouchTool and set up a custom action for DEVONThink for a keyboard combination to use. Read more…

By mnott on 2013/09/10 | Code, Computer, Research, Science

Apple Time Machine – get back in the Driver’s Seat!

Background

Maybe it is just me again overcomplicating things. Yet I recently noticed that when I went on my VPN, using my IPhone to connect to the Internet, and then OpenVPN, at some point, TimeMachine decided to run a backup. Not the best idea in the world even if you are not on a world-wide flat rate, as it will eat up all your internet bandwidth (and also your data plan and hence pocket money if you’re not on a flat rate.)

Unfortunately, TimeMachine, like so many other of Apple’s products, are created for people who Apple apparently considers too dumb to configure anything about – and hence there’s not so much you can configure using their visual tools. I was having one external (USB) disk as TimeMachine target, and one network attached storage (actually a larger server I’m hosting, exposed through netatalk / AFP).

Now TimeMachine having two targets will just cycle through them. If you happen to be on the go, and just “appear” to be home (using VPN), then, well, see above.

Fortunately I saw that Apple provides for a small command line utility, tmutil, which you can utilize to control TimeMachine better. Yet as I’m a strong believer in Wall’s three fundamental virtues of any great programmer, one of which is laziness, I’m definitely too lazy to remember command line options, type stuff by hand, etc. That’s why I utilized today’s lunch break to come up with a quickly hacked together small Perl script which wraps tmutil (i.e., you can use it as a proxy), which gets you back in the driver’s seat. The File is attached, here’s how it works.

Read more…

By mnott on 2013/06/03 | Code, Computer | 2 comments

Export from VitalSource Bookshelf

Every now and again, my University gives us a reader through the DRM black hole software that they deemed useful to license: VitalSource bookshelf. And of course, that means you’ll get encrypted content, which your operating system and document management system of choice won’t index. And just as with Adobe Digital Editions (but more uncomfortably than over there), there’s ways out of that. Read more…

By mnott on 2013/05/01 | Code, Research, Science

Users vs. Programmers

By mnott on 2011/10/17 | Code, Computer | 1 comment

New OCR Wrapper published on Sourceforge

I’ve shared a small project I’ve recently written on sourceforge: pdfocrwrapper.sourceforge.net This tool serves as a wrapper around the excellent ABBYY OCR engine which also exists as a Linux variant. The wrapper recursively iterates a directory structure and submits all PDF that it finds (and that it has not yet worked on) to ABBYY. The wrapper is of course flexible enough to work with other engines.

With this wrapper, you can keep scanning all your documents into PDFs. The wrapper will run, asynchronously, over those PDFs and apply the OCR engine to them. As a result, you’ll be able to index and search the content of these files.

By mnott on 2010/07/01 | Code, Research | A comment?

How to manage virtual mail domain aliases with ISPConfig 3

Here’s a small script I’ve implemented as a MySQL stored procedure that allows you to include a virtual domain mapping scheme for the Version 3.0 of ISPConfig.

ISPConfig – see www.ispconfig.org – is an excellent tool for managing virtual domains on a shared mail/webserver. The thing that I found missing was that if a customer has multiple domains and wants to make sure that an email to a named user of his company will arrive in that user’s inbox will actually come out in his inbox regardless of the domain to which the email was sent, we need to manage multiple domain aliases automatically, as we obviously do not want to manage each user account in what may be 10 different domains.

On the file system side, we’re creating symlinks for the different subdirectories in /var/vmail, so that the mails are automagically available regardless of the domain the user is going to work with.

There also is a cleanup script – and you by the way need to make sure that if you do not have aliases for one given domain, you still add an entry to the alias table mapping the domain to itself – or the cleanup script will just remove all the members of that domain (or you change the cleanup script).

I’m giving the tool in one block, so have fun with it. I did submit it to the ISP developers, as well.

M

By mnott on 2009/02/04 | Code | A comment?