filter

How to drop the first matching element in a Scala sequence

Summary: This blog post shows one way to drop/filter the first matching element from a Scala sequence (Seq, List, Vector, Array, etc.). I don’t claim that the algorithm is efficient, but it does work.

Background

While creating some Scala test code earlier today I had an immutable list of toppings for a pizza, and I got into a situation where I wanted to remove the first instance of a topping.

How to write a Scala shell script that reads input from STDIN alvin March 11, 2017 - 5:06pm

As a quick note, if you need an example of how to write a Scala shell script that reads from STDIN (standard input) and writes to STDOUT (standard output), this code shows a solution:

#!/bin/sh
exec scala -savecompiled "$0" "$@"
!#

import scala.io.StdIn

var line = ""
while ({line = StdIn.readLine(); line != null}) {
    println(line)
}

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.

More examples of working with Gimp effects (filters)

In a previous article I shared a catalog of examples of Gimp filter effects. In this brief article/pictorial I’ll share examples of some of my favorite Gimp effects on a favorite image of a favorite dog. I don’t have a particular goal in this work, I just want to try out some different filters and effects and see where they lead.

The raw image

Here’s a raw image of a Siberian Husky named Zeus that I knew very well:

A gallery of 130+ Gimp filters/effects

There are times when I work on images a lot with Gimp, and then there are times when I don’t work with Gimp for a month or two. When I don’t work with Gimp a lot, I tend to forget about all of the different things I can do with. Therefore, I have created this page as a “Gimp special effects cheat sheet” page to help remind me of all the cool things I can do with Gimp effects.

How to remove extended ASCII characters from Unix files with the 'tr' command

When working with text files on a Unix/Linux system, you'll occasionally run into a situation where a file will contain extended ASCII characters. These extended characters will generally appear to begin with ^ or [characters in your text files. For instance, the vi/vim editor will show ^M characters in DOS text files when they are transferred to Unix systems, such as when using the ftp command in binary transfer mode. Oftentimes, you'll want to easily delete these characters from your files.

Wedding photo

One of my nieces got marries recently, and I created this “cartoonized” image from a wedding photo using Gimp. It probably took about ten steps in this case, but I had to significantly reduce the light coming in the large window behind them; pump up the color a lot; apply several “artistic” filters to it (Van Gogh and Oilify, several times each); and then kept applying different levels of the “cartoon” effect. I didn’t really want a cartoon image, but I couldn’t get the Oilify image to look the way I wanted in the time allotted, so I applied the Cartoon filter, and I was happier with it.

Scala: A quick look at the Slick database library

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 16.9, “A quick look at the Slick database library.”

How to list subdirectories beneath a directory in Scala

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 12.10, “How to list subdirectories beneath a directory in Scala.”

Problem

You want to generate a list of subdirectories in a given directory.

Solution

Use a combination of the Java File class and Scala collection methods: