script

How to install Script-Fu scripts to work with Gimp (Mac OS X)

I couldn’t get the Gimp “Reflection” filter to work (on Gimp 2.8), so after a little digging around I found that the GimpHelp.org website has kept some of the Gimp scripts — called Script-Fu scripts — up to date. So I downloaded those scripts, and then had to figure out how to make them work in Gimp.

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

How to make your Scala shell scripts run faster by pre-compiling them

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is a short recipe, Recipe 14.13, “How to make your Scala shell scripts run faster by pre-compiling them.”

Problem

You love using Scala as a scripting language, but you’d like to eliminate the lag time in starting up a script.

Solution

Use the -savecompiled argument of the Scala interpreter to save a compiled version of your script.

A basic Scala script like this:

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

How to prompt users for input from Scala shell scripts alvin June 20, 2015 - 4:37pm

This is an excerpt from the Scala Cookbook, partially modified for the internet. This is Recipe 14.12, “How to prompt users for input from Scala shell scripts.”

Back to top

Problem

You want to prompt a user for input from a Scala shell script and read her responses.

Back to top

Solution

Use the readLine, print, printf, and Console.read* methods to read user input, as demonstrated in the following script. Comments in the script describe each method:

Table of Contents

  1. Problem
  2. Solution
Back to top
How to access command-line arguments in Scala shell scripts alvin June 20, 2015 - 4:34pm

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 14.11, “How to access command-line arguments in a Scala shell script.”

Problem

You want to access the command-line arguments from your Scala shell script.

Solution

Use the same script syntax as shown in Recipe 14.8, “Generating Documentation with scaladoc”, and then access the command-line arguments using args, which is a List[String]` that is implicitly made available:

How to use Scala as a scripting language

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 14.10, “How to use Scala as a scripting language.”

Back to top

Problem

You want to use Scala as a scripting language on Unix systems, replacing other scripts you’ve written in a Unix shell (Bourne Shell, Bash), Perl, PHP, Ruby, etc.

Back to top

Solution

Save your Scala code to a text file, making sure the first three lines of the script contain the lines shown, which will execute the script using the scala interpreter:

Table of Contents

  1. Problem
  2. Solution
Back to top

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

Mac OS X: ‘sed’ commands I use to clean MacDown HTML output alvin June 13, 2015 - 1:58pm

FWIW, this is the source code for a sed script I use on my Mac OS X system to convert HTML output generated by MacDown into a format I need. MacDown generates some extra “cruft” that I don’t need, so I use these sed commands to clean up that HTML output:

Raspberry Pi camera module shell script alvin January 13, 2015 - 2:42pm

As a quick note today, this is the source code for a Raspberry Pi (RPI) camera module shell script that I created so a friend can turn her Raspberry Pi camera on and off from the RPI command line (Linux command line):

Converting PDF content to plain text with Scala (or Java) alvin November 15, 2014 - 2:22pm

I recently wrote a little application to convert pages from a PDF to plain text. The GUI portion of the application looks like this:

As you can see, the application just needs the name of a PDF file to convert, along with the page you want to start at and the page you want to end at. There are several ways I could make the application more convenient to use, but since I don't plan to use it that often, I can deal with its limitations.

How to get the IP address of a Linux system from the command line

One way to to get the IP address of a Linux system from the Linux command line is this:

$ hostname -I

That’s the hostname command, followed by a capital letter i as a command line parameter. On my Raspberry Pi system, this command returns its IP address — and only its IP address — like this:

10.0.1.9

It’s nice that this command returns only the IP address, because that means I don’t have to pipe together several commands to get what I need.

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

Complete backup scripts for my websites (Drupal, MySQL)

I’m spending a little time today trying to automate the process of backing up my websites, and in doing so I thought I would share the Linux shell scripts that I use to generate the backup files, including backups of my MySQL databases and Drupal website directories. If you are comfortable with shell programming in Linux, I think you’ll be able to follow the code in the following scripts.

MySQL database backup script

First, this is a backup script I use to backup a MySQL database:

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.