parameters

A Play Framework 2.6 startup script example (Scala)

Play Framework FAQ: Can you share an example of a Play Framework 2.6 startup script, i.e., a shell script that shows the commands and parameters you use to run a Play Framework application?

Sure. Assuming that you created a production mode version of your application with the sbt dist command, deployed that zip file to a production server, and have a Play Framework 2.6 application named “myapp,” you can put a command like this in a Unix/Linux shell script to start your Play application:

A Scala shell script to read HTML H1 tag attributes

I’m putting this Scala shell script out here as a “source code snippet” so I can find it again if I need it. This file reads an input file that contains a series of HTML <h1> tags. I use this as part of a process of publishing an Amazon Kindle ebook from an HTML file, and in one of the steps of the creation process, I use this script to help create the Table of Contents (TOC) for the book.

Here’s the source code:

The Java 8 lambda Thread and Runnable syntax and examples

As a quick note, here are some examples of the Java 8 lambda Thread and Runnable syntax. As a little bonus I also show the Java lambda syntax in other situations, such as with an ActionListener, and several “handler” examples, including when a lambda has multiple parameters.

My Android AsyncTask docs and examples (parameters, callbacks, executing, canceling)

I’ve currently written this document as a “note to self” about how the Android AsyncTask works. It’s currently incomplete, but if you want to know how an AsyncTask works, most of the answers are generally here. I provide documentation for most aspects of the AsyncTask, though my coverage of (a) updating progress/status and (b) canceling an AsyncTask is a little weak atm.

This is a page from my book, Functional Programming, Simplified

Partially-Applied Functions (and Currying)

Motivation

My motivations for writing this lesson are a little different than usual. Typically I think, “You’ll want to know this feature so you can use it like ___,” but the first motivation for this lesson goes like this: You’ll want to know about the concept of “currying” because experienced FP developers talk about it a lot, especially if they have Haskell programming experience. (I did mention that Haskell was named after Haskell Curry, didn’t I?)

This is a page from my book, Functional Programming, Simplified

How to Write and Use Scala Functions That Have Multiple Parameter Groups

“Logic clearly dictates that
the needs of the many outweigh the needs of the few.”

Spock in Star Trek II: The Wrath of Khan

Introduction

Scala lets you create functions that have multiple input parameter groups, like this:

Gimp “Script-Fu” example (functions, parameters) alvin August 6, 2016 - 6:13pm

I’ve mentioned this before, but if you’re interested in learning Lisp/Scheme programming, the makers of gimphelp.org have a nice collection of plugins for Gimp 2.8 that you can download, and they’re all written in Scheme. (Well, a variation of Scheme.)

Here’s the body of a Gimp plugin file named FU_contrast_auto-contrast.scm:

How to access Scalatra web service GET parameters

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is a short recipe, Recipe 15.7, “How to access Scalatra web service GET parameters.”

Problem

When creating a Scalatra web service, you want to be able to handle parameters that are passed into a method using a GET request.

Solution

If you want to let parameters be passed into your Scalatra servlet with a URI that uses traditional ? and & characters to separate data elements, like this:

How to set default values for Scala method parameters

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 5.3, “How to set default values for Scala method parameters.”

Problem

You want to set default values for method parameters so the method can optionally be called without those parameters having to be assigned.