example

How to create a LibGDX Dialog (example) alvin December 27, 2017 - 8:25pm

If you ever need to create a Dialog in LibGDX, I can confirm that this example code works:

A collection of 100+ Scala String examples

This page contains a collection of over 100 Scala String examples, including strings functions, format specifiers, and more. I don’t provide too many details about how things work in these examples; this is mostly just a collection of examples that can be used as a reference page or cheat sheet. (I do show the output of most examples.)

First, here are some basic uses of the Scala String class to help get us warmed up:

Source code for an Android AsyncTask (REST client) example

I just got back into using an Android AsyncTask, and it took me a little while to re-load the concepts in my head. I used AsyncTask’s a few years ago, but haven’t used them since.

To help remember how they work, I created a little AsyncTask example project, and I’ve included all of the source code for that project here. I’ll show all of the source code for my classes and configuration files, and then explain the code at the end.

The SBT syntax to add multiple library dependencies (Scala) alvin March 6, 2017 - 3:13pm

As a quick note, the Scala Simple Build Tool (SBT) syntax to add multiple library dependencies is this:

libraryDependencies ++= Seq(
    "com.typesafe.akka" %% "akka-actor" % "2.1.1",
    "com.typesafe.akka" %% "akka-remote" % "2.1.1"
)

An Akka actors ‘remote’ example

While doing some crazy things with SARAH, I realized that the best way to solve a particular problem was to use remote Akka actors. I haven’t had the opportunity to work with Akka much since finishing the Scala Cookbook, so I dug around trying to find a simple Akka remote “Hello, world” example. Unable to find a good one, I read some stuff, and created it myself.

“Alexa written with Akka” = Aleka

Table of Contents1 - Background2 - Assumptions3 - 1) Create an SBT project4 - 2) Create a Scala app5 - 3) Messages6 - 4) The brain7 - 5) The mouth8 - 6) The project directory structure9 - 7) Running the application10 - The source code11 - What’s next

As a way of demonstrating how to write code with Akka, Scala, and functional programming (FP), I started creating a new project this weekend. I named it Aleka, because it may eventually be like Amazon’s Echo/Alexa, written with Akka (and Scala).

(I suppose a better name might be “Ekko,” after Echo, but I have a niece named Aleka, so unless she objects, this works for me.)