script

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:

This website is a little one-man operation. If you found this information helpful, I’d appreciate it if you would share it.

How to use `curl` scripts to test RESTful web services

Table of Contents1 - GET, POST, DELETE, and PUT examples2 - More POST examples3 - Headers returned by the server4 - Discussion5 - Summary

There may be better ways to do this, but as I’m writing a mobile app with the client written in Sencha Touch, and the server written with the Play Framework, I’ve written some curl scripts to simulate GET, POST, DELETE, and PUT request (method) calls to my Play Framework “RESTful” services.

This website is a little one-man operation. If you found this information helpful, I’d appreciate it if you would share it.

A Scala shell script to insert text before a matching pattern

I don’t remember exactly why I wrote this Scala shell script, but if I remember right I was having a problem getting sed to work properly, so I wrote this little script to insert an Amazon Kindle “break” tag before each <h1> tag in an HTML file:

This website is a little one-man operation. If you found this information helpful, I’d appreciate it if you would share it.

A Scala “Word of the day” shell script

I have a 19" monitor on the counter between my kitchen and living room, and it’s powered by a Raspberry Pi. I use the Linux Phosphor screen saver to show a scrolling “news and stock ticker” on the display, which I’ve programmed to show news from several different sources (Atom and Rss feeds, along with other news and data sources). An old version of the display looks like this:

My Raspberry Pi news ticker display

Today I added a new “Word of the day” feature to the display, and as with all of the other code, I wrote a Scala shell script to generate the output.

This website is a little one-man operation. If you found this information helpful, I’d appreciate it if you would share it.

Unix/Linux code to test whether “today” is a weekend day (or weekday) alvin January 27, 2018 - 7:40am

If you ever need an example of a Unix/Linux shell script where you need to determine whether today is a weekend day, I can confirm that this code works:

Linux: How to get the basename from the full filename

As a quick note today, if you’re ever writing a Linux shell script and need to get the filename from a complete (canonical) directory/file path, you can use the Linux basename command like this:

$ basename /foo/bar/baz/foo.txt
foo.txt

This website is a little one-man operation. If you found this information helpful, I’d appreciate it if you would share it.

sed on macOS: How to append multiple lines of text to an HTML or XML file

As a brief note about the Linux/Unix sed command, today I learned how to append multiple lines of text to an HTML (or XML) file on macOS. The short answer is that I created a sed commands file named changes.sed with these contents:

This website is a little one-man operation. If you found this information helpful, I’d appreciate it if you would share it.

How to write a Scala shell script that reads input from STDIN

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)
}

This website is a little one-man operation. If you found this information helpful, I’d appreciate it if you would share it.

How to process every line in a file with a Unix/Linux shell script

Unix/Linux shell script FAQ: How do I write a Unix or Linux shell script where I "do something" for every line in a text file?

Solution: An easy way to process every line in a text file is to use a Unix/Linux while loop in combination with the Linux cat command, like this:

This website is a little one-man operation. If you found this information helpful, I’d appreciate it if you would share it.

Example: How to use javapackager to build a MacOS application bundle

Table of Contents1 - Building a MacOS application bundle with javapackager2 - The longer story3 - The Mac/Java class4 - The three scripts5 - javapackager notes

I recently learned how to use the Java javapackager command to build a macOS application bundle — i.e., a regular macOS application — from a Java application. In this tutorial I’ll show how to create a Mac application bundle from a simple Java class, in this case a Java Swing class.

This website is a little one-man operation. If you found this information helpful, I’d appreciate it if you would share it.