Ubuntu: How to reschedule mlocate

What is mlocate can be found here.

By default it is scheduled to execute daily – that might not meet your expectations what you computer should do when you power it up.

Here is how to reschedule it to execute weekly:

### In the terminal
sudo chmod -x /etc/cron.daily/mlocate
sudo cp /etc/cron.daily/mlocate /etc/cron.weekly/mlocate
sudo chmod +x /etc/cron.weekly/mlocate

This has been checked with Ubuntu 18.04 LTS.

Scala: links

Collections

Reduce, fold or scan (Left/Right)?

Functional programming

Building a Scala Sequence in a Functional Style

Demystifying monads in Scala

Concurrency

Which shoe fits you? Comparing Akka Streams, Actors, and Plain Futures

Scala – Execution Order when Mapping Over Twitter Futures

ScalaZ 8 vs AKKA

An introduction to Finagle

import com.twitter.util.{Await, Future, Promise}
class User(n: String) { val name = n }
def isBanned(u: User) = { Future.value(false) }
val pru = new Promise[User]
val futBan = pru flatMap isBanned
pru.setValue(new User("prudence"))
Await.result(futBan)
import com.twitter.util.{Await, Future, Promise}
class User(n: String) { val name = n }
def isBanned(u: User) = { Future.value(false) }
val pru = new Promise[User]
val futBan = pru.flatMap(isBanned)
pru.setValue(new User("prudence"))
Await.result(futBan)
import com.twitter.util.{Await, Future, Promise}
class User(n: String) { val name = n }
def isBanned(u: User) = { Future.value(false) }
val pru = new Promise[User]
pru.setValue(new User("prudence"))
val futBan = for { futUser <- pru; futIsBanned <- isBanned(futUser) } yield futIsBanned
Await.result(futBan)

Traits

To trait, or not to trait?
Traits
Scala traits implementation and interoperability. Part I: Basics
Scala traits implementation and interoperability. Part II: Traits linearization
Scala Trait and Mixin – Points to Remember
Is Traits in Scala an Interface or an Abstract Class?

Sealed traits

Everything You Ever Wanted to Know About Sealed Traits in Scala
More on Sealed Traits in Scala
Sealed Traits & Functions Referencing Sub-classes?

Typesafe Config

Configuration library for JVM languages
Typesafe Config Features and Example Usage
Environment aware configuration with Typesafe Config

Scala on Raspberry PI

Scala – IOT : First basic IOT application using Scala on RaspberryPi

 

 

WordPress: changing permalink settings and 404 page not found

Taken from:

To be able to change permalink settings you might need to change access rights of the /var/www/html/<blogfolder>/.htaccess from 644 to 666:

### On your web server
$ cd /var/www/html/<blogfolder>
$ sudo chmod 666 .htaccess
### Do not forget to change back to 644 after you are done with permalinks
$ sudo chmod 644 .htaccess

If after changing WordPress permalink settings you get notorious “404 page not found” then check that the bold options in the <Directory /var/www/> section in the /etc/apache2/apache.conf file look like this:

<Directory /var/www/>
 Options Indexes FollowSymLinks
 AllowOverride All
 Require all granted
</Directory>

OpenSSL hints

Environment
  • Ubuntu 16.04 LTS
  • OpenSSL 1.0.2g 1 Mar 2016
Download server certificate
### Show certificate
$ openssl s_client -connect host:port -showcerts
### Download certificate
$ echo | openssl s_client -connect host:port 2>&1 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > server.crt.pem
2-way TLS authentication test

Say, we’ve downloaded server certificate and generated your client private key and certificate. Now we want to test if everything works:

$ openssl s_client -connect hostname:port -CAfile server.crt.pem -cert client.crt.pem -key client-private.key.pem

If you private key is protected with a password you’ll be prompted to enter the password.

 

 

 

 

Raspberry Pi: Flower Care (aka MI Flower) sensor

Environment
  • Raspberry Pi 3 Model B
Flower Care sensor

See http://www.huahuacaocao.com/product.

Looks and feels very nice:

Be aware that there are two versions of the sensor – Chinese and  international. I saw complains on internet about chinese sensor that were bricked after software upgrade when used outside of China. It is not quite clear what exactly was bricked – mobile phone app or the sensor itself.

Python demo on Raspbery Pi

Details see on GitHub.

$ git clone https://github.com/open-homeautomation/miflora.git
$ cd miflora/
$ . ./build.sh 
$ python3 setup.py build
$ sudo python3 setup.py install
$ python3 demo.py C4:7C:8D:xx:xx:xx
Getting data from Mi Flora
FW: 2.7.0
Name: Flower care
Temperature: 18.3
Moisture: 27
Light: 105
Conductivity: 59
Battery: 100

 

Raspberry Pi: installing Mosquitto MQTT broker

Environment
  • Raspberry Pi 3 Model B

Taken from: YouTube.

Installation
$ sudo apt-get update
$ sudo apt-get dist-upgrade
### Install mosquitto
$ sudo apt-get install mosquitto
### Install mosquitto clients
$ sudo apt-get install mosquitto-clients
Testing
### Console 1
$ mosquitto_sub -t "hellomosquitto"

### Console 2
$ mosquitto_pub -t "hellomosquitto" -m "Hello, Mosquitto!"

### Console 1 will print
Hello, Mosquitto!

 

Raspberry Pi: cross-compile Boost libraries

Environment
  • Ubuntu 16.04 LTS
  • arm-linux-gnueabihf (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
  • Raspberry Pi 3 Model B
Install toolchain

See C++ cross-compiling.

Download boost source code

Boost source on Sourceforge. In my case boost_1_63_0.tar.bz2.

Compile

Say, we need boost-iostreams, installation folder /usr/local/boost:

# Unpack the archive
$ tar --bzip2 -xf boost_1_63_0.tar.bz2
$ cd boost_1_63_0
$ ./bootstrap.sh
# In the project-config.jam file replace
# using gcc ;
# by
# using gcc : arm : arm-linux-gnueabihf-g++ ;
$ sudo ./bjam install toolset=gcc-arm --prefix=/usr/local/boost --with-iostreams