A database query for implementing paging in a Play Framework application alvin April 25, 2018 - 1:28pm

As a quick note to self, one way to implement paging in a Play Framework application is to use the limit and offset arguments in a MySQL query. This way you can show X number of objects on one web page, then give the user Next and Previous links so they can scroll backwards and forwards through the dataset.

To implement paging with a MySQL query, use the limit and offset query parameters, as shown in this example:

How to transfer very large files to an Android device with adb alvin December 13, 2017 - 8:26pm

Today I learned that the Android File Transfer tool has a 4GB data transfer limit, but I was able to get around that by using the adb (Android Debug Bridge) command. The short story is that I used this adb command to transfer a 6GB file to my Android system, an old Nexus 9:

Scala: How to limit which classes can use a trait by inheritance

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 8.5, “How to limit which classes can use a trait by inheritance.”


You want to limit a trait so it can only be added to classes that extend a superclass or another trait.

Perl random numbers (tutorial, examples)

Perl random number FAQ: Can you show me some examples of how to get a random number in Perl?

Perl random number - solution

In its simplest form, if you just need a random decimal number between 0 and 1.0, you can use the Perl rand function like this:

# generate a random number in perl with the rand function

my $random_number = rand();
print $random_number, "\n";

When I save this Perl random number code to a file and run it three times, I get these results:

CakePHP find - a SQL limit query example (SQL select with limit clause)

When working with CakePHP, one of the hardest things for me has been getting used to formulating SQL queries with the CakePHP find method syntax. Today I needed to run a SQL query where I limited the amount of records returned from the database, and after a little trial and error, I found the correct CakePHP SQL LIMIT syntax, and thought I'd share that here today.

Solving the MySQL "can't create/write to file" error message

Two MySQL error messages

Earlier this week I ran into a problem with a website that I tracked down to a MySQL error message that looked like this:

can't create/write to file /var/lib/mysql/
Errcode: 23

(The actual file referenced in that error message doesn't matter, as it will be different on most systems, but the "can't create/write to file" is important.) After digging through my log files even more, I also found this error message related to MySQL: