How to Set Up DynamoDB for Local Development

In this article we are going to set up dynamodb on our local development environment. A short description of a couple of easy-to-use management tools is included. DynamoDB Start by downloading the DynamoDB development version. Uncompress the file and create a launch script with the following contents: #!/bin/sh java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb -port 8000 The script will launch dynamo on port 8000 and will create a file called shared-local-instance.

Monoid definition and examples

We are going to cite the definition of a Monoid found on this post: Conceptually, a monoid is anything that: - Has a "zero-value": `mempty`, e.g., `0` - Can be "appended" together: `mappend`, e.g., `+` - Has an identity with the zero-value: `x + 0 == x, 0 + x == x` - Is associative: `x + y + z == (x + y) + z == x + (y + z)` This isn’t limited to just arithmetic with operators like +.

Creating an sbt project from scratch

Files and project structure sbt projects use the same structure as Maven. Creating a project from scratch involve the following steps: mkdir some-new-project cd some-new-project mkdir -p src/{main,test}/{resources,scala} mkdir project Create a new file called build.sbt and add the following contents: name := "SomeNewProject" version := "1.0" scalaVersion := "2.13.5" Our final folder structure has to look like this: . ├── build.sbt ├── project └── src ├── main │ ├── resources │ └── scala └── test ├── resources └── scala Done.

Sending a message using telegram and scala

In this article we are going to use scala to send a message via Telegram. The process is very simple and pretty much involves setting up a bot and making a GET request to Telegram’s api. The Telegram app on the phone has more features than its desktop counterpart. I recommend you to use the phone version to make sure you have access to all the required features. On Telegram 1.

How to create a self-contained jar file (fat jar) using sbt

A fat jar is a jar file that contains any dependencies required by a Java or Scala program. Deployment becomes an easy task if we only have to deal with one single file. In this article we’ll go through the steps required to create a fat jar using Scala and sbt. The following procedure has been tested using Scala 2.12.8, sbt 1.2.8 and jdk 11. 1. project/assembly.sbt Create project/assembly.

Add your GMail account to MetaTrader Notifications

On this article we’re going to set up Metatrader for email sending. This is recommended so you don’t miss important messages happening to your account. Getting a password from Google If you want to connect your Google email account, you have to generate a new password for Metatrader. To generate a Google password: On the GMail page click on the Apps menu at the top right corner and then click on Account.

Implementing put and delete operations using BatchWriteItem

The BatchWriteItem operation allows us to work with groups of up to 25 items per request. Additionally, we can put and delete items to one or multiple tables. Amazon DynamoDB’s page says: A single call to BatchWriteItem can write up to 16 MB of data, which can comprise as many as 25 put or delete requests. Individual items to be written can be as large as 400 KB. In this article we are going to go through the process of putting and deleting items to a table that looks like this:

Undoing the Last Git Commit

A command so important, it deserves its own page: git reset --soft HEAD~1 The previous command undoes the last commit to git. I think this is one of those commands that I have typed many times during the last year. It’s very important to know which branch we currently are on, but sometimes excitement (or stress) may make us forget checking it. If this is not enough, then we can reset our branch to master like this: (this will lose all our changes):

Inserting and updating items to DynamoDB lists and maps

Should I use a map or a list? A simple rule: If you need to update or remove an item, lists only allow you to do it by index. While maps let you do it by key. Their simplified representation goes like this: { "someMap": { "key1": "value1", "key2": "value2", }, "someList": ["value1", "value2"] } Inserting and updating to a map The following example adds or updates an instance of “SomeItem” as a json string into a map field called someMapField.

Testing scala classes and controllers

This article discusses different approaches for testing classes, services, and PlayFramework controllers using scalatest. Setting up the project dependencies First step is to add to build.sbt the next dependency: "org.scalatest" %% "scalatest" % "3.2.2" The following template unit test uses the WordSpec style which offers a natural way for writing tests. scalatest offers more styles, but I find this one more expressive. PlaySpec (found in the PaylFramework) extends WordSpec and has a similar behavior.