Skip to main content

How to Build WatermelonDB Sync Backend in Elixir

· 13 min read
Fahri Nurul Hidayat
Software Engineer

WatermelonDB​

WatermelonDB is a reactive database for React frontend application that supports data synchronization.

WatermelonDB

What I like about this database is you can bring your own sync backend (HTTP-based) as long as it complies with this spec:

OperationRequest Params / BodyResponse Body
Pull- lastPulledAt: integer, Unix time in milliseconds (ms)- changes: (JSON)
- timestamp: integer, Unix time in milliseconds (ms)
Push- changes: (JSON)
- lastPulledAt: integer, Unix time in milliseconds (ms)
X

The following is a brief how pull and push operation works. Please refer to Sync documentation for the details

File Downloading in Headless Chrome Using ChromeDriver and Hound

· 4 min read
Fahri Nurul Hidayat
Software Engineer

Recently, I am making a simple Elixir application performing some actions to a website in an automated way.

The automated testing tool is a perfect candidate to be used to help to build application like that. I use Hound as browser automation library and Chrome as a controlled browser. For the browser driver, I use ChromeDriver.

How to Update Pomera DM100 Firmware

· 3 min read
Fahri Nurul Hidayat
Software Engineer

Pomera DM100 is a distraction-free digital writing tool. Think mini laptop with only text editor application loaded.

It comes from Japan. It means its manual is in all Japanese. It becomes hard when you want to do the crucial procedure (like upgrading firmware) AND Google Translate doesn't help you much.

I can only follow some steps in its updating guide web page and the rest of important steps in PDF are not translatable by Google Translate.

In the end, I have successfully updated my Pomera DM100 to the latest firmware.

Here are the steps:

Java: How To Autodetect The Charset Encoding of A Text File and Remove Byte Order Mark (BOM)

· 3 min read
Fahri Nurul Hidayat
Software Engineer

TLDR;​

Required dependencies (pom.xml) :

<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
<version>60.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>

Autodetect the charset encoding of a text file or input stream then 'remove' (skip) Byte Order Mark (BOM) while reading based on detected charset :

File inputFile = new File("/Users/fahri/Downloads/UNKNOWN_TEXT.txt");

BOMInputStream bomInputStream = new BOMInputStream(new BufferedInputStream(new FileInputStream(inputFile)),
ByteOrderMark.UTF_8, ByteOrderMark.UTF_16BE, ByteOrderMark.UTF_16LE, ByteOrderMark.UTF_32BE, ByteOrderMark.UTF_32LE);

System.out.println("HAS BOM : " + bomInputStream.hasBOM());

CharsetDetector detector = new CharsetDetector();
detector.setText(bomInputStream);

CharsetMatch charsetMatch = detector.detect();
System.out.println("CHARSET MATCH : " + charsetMatch.getName());

BufferedReader br = new BufferedReader(new InputStreamReader(bomInputStream, charsetMatch.getName()));
for (String line = br.readLine(); line != null; line = br.readLine()) {
System.out.println(line);
}
br.close();

Oracle XE 11g with Docker

· One min read
Fahri Nurul Hidayat
Software Engineer
$ docker pull wnameless/oracle-xe-11g
$ docker run -d -p 1022:22 -p 1521:1521 -e ORACLE_ALLOW_REMOTE=true wnameless/oracle-xe-11g
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4fe7a1024ed3 wnameless/oracle-xe-11g "/bin/sh -c '/usr/..." 5 weeks ago Exited (137) 4 days ago practical_williams
$ docker start practical_williams
# or
$ docker start 4fe7a1024ed3

Static Blogging with Hugo, GitHub Pages (Travis CI, Cloudflare)

· 2 min read
Fahri Nurul Hidayat
Software Engineer

Github​

Hello World

· One min read
Fahri Nurul Hidayat
Software Engineer
class HelloWorld {
static public void main( String args[] ) {
System.out.println( "Hello World!" );
}
}
fun main(args : Array<String>) {
println("Hello, world!")
}
console.log("Hello World");
defmodule HelloWorld do
IO.puts "Hello, World!"
end
package main

import "fmt"

func main() {
fmt.Printf("Hello World\n")
}