Exploring the Physical Web

Physical Web

Introduction

Objects around you that are part of the Physical Web send Bluetooth signals to your phone. When you’re in range, you’ll see a list of suggested webpages.

Client side

You can run the client app on your smart phone that will through bluetooth to scan any objects nearby you. And list out the URLs. (hints: I found a Brother’s printer on the app)
iOS app store
Android

Server side

You can build you only Physical Web in few steps really quick.
https://apkpure.com/beacon-toy/com.uriio

Reference

https://google.github.io/physical-web/
https://github.com/google/physical-web


Setup SMART on ubuntu server

Ubuntu

Installation

1
apt-get install smartmontools

Configuation

1
2
3
4
5
6
7
8
9
10
11
12
13
cat /etc/default/smartmontools
# file content
enable_smart="/dev/sda /dev/sdb"
start_smartd=yes
smartd_opts="--interval=1800"


cat /etc/smartd.conf
# file content
DEVICESCAN -d removable -n standby -m root -M exec /usr/share/smartmontools/smartd-runner
/dev/sda -a -o on -S on -s (S/../.././02|L/../../6/03)
/dev/sda -H -l error -l selftest -t -I 194
/dev/sda -H -C 0 -U 0 -m calvin@test.com.tld

Start Service

1
2
/etc/init.d/smartd start
systemctl enable smartd

Log

1
cat /var/log/syslog

Docker compose error (mem_limit)

Docker

Senario

When you try to run container with ./docker-compose.yml file, you will get below error message.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Traceback (most recent call last):
File "docker-compose", line 6, in <module>
File "compose/cli/main.py", line 71, in main
File "compose/cli/main.py", line 121, in perform_command
File "compose/cli/command.py", line 37, in project_from_options
File "compose/cli/command.py", line 91, in get_project
File "compose/config/config.py", line 375, in load
File "compose/config/config.py", line 506, in process_config_file
File "compose/config/config.py", line 497, in interpolate_config_section
File "compose/config/interpolation.py", line 44, in interpolate_environment_variables
File "compose/config/interpolation.py", line 44, in <genexpr>
File "compose/config/interpolation.py", line 39, in process_item
File "compose/config/interpolation.py", line 39, in <genexpr>
File "compose/config/interpolation.py", line 54, in interpolate_value
File "compose/config/interpolation.py", line 74, in recursive_interpolate
File "compose/config/interpolation.py", line 74, in <genexpr>
File "compose/config/interpolation.py", line 70, in recursive_interpolate
File "compose/config/interpolation.py", line 184, in convert
File "compose/config/interpolation.py", line 141, in to_int
ValueError: invalid literal for int() with base 0: '512m'
Failed to execute script docker-compose

Summary

The value of mem_limit no more supported with recent docker-compose (1.18.0)

Hot-fix

Just edit your docker-compose.yml and remove mem_limit lines. The best soloution should be replace as RESOURCES.

1
2
3
4
5
6
7
8
# backup your file
cp -a docker-compose.yml docker-compose.yml.bak

# trim mem_limit
cat docker-compose.yml.bak |grep -v "mem_limit" > docker-compose.yml

# then run again
docker-compose up

Reference

https://support.zabbix.com/browse/ZBX-13224
https://docs.docker.com/compose/compose-file/#resources


Docker ubuntu container network utilities

Docker

Senario

When you need to debug the container you may need some network tools.

1
docker exec -it your_container_name bash

Packages

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
apt-get update
apt-get install -y iputils-ping telnet dnsutils net-tools inetutils-traceroute

# You must run update before your installation
apt-get update

# ping google.com
apt-get install iputils-ping

# telnet google.com 80
apt-get install telnet

# nslookup google.com
# host google.com
apt-get install dnsutils

# netstat, arp
apt-get install net-tools

# traceroute google.com
apt-get install inetutils-traceroute


Bad Sector and MySQL innodb

MySQL

StdErr

Thats shown on screen

1
2
3
4
WARNING: Your hard drive is failing
Device: /dev/sda [SAT], 8 Currently unreadable (pending) sectors
WARNING: Your hard drive is failing
Device: /dev/sda [SAT], 8 Offline uncorrectable sectors

SMART Log

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# sudo smartctl -a /dev/sda
...
...
SMART Error Log Version: 1
ATA Error Count: 25 (device log contains only the most recent five errors)
...
...
Error 25 occurred at disk power-on lifetime: 6502 hours (270 days + 22 hours)
When the command that caused the error occurred, the device was active or idle.

After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
40 51 00 ff ff ff 0f Error: UNC at LBA = 0x0fffffff = 268435455

Commands leading to the command that caused the error were:
CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
-- -- -- -- -- -- -- -- ---------------- --------------------
25 00 08 ff ff ff ef 00 14d+16:54:04.035 READ DMA EXT
27 00 00 00 00 00 e0 00 14d+16:54:04.031 READ NATIVE MAX ADDRESS EXT [OBS-ACS-3]
ec 00 00 00 00 00 a0 00 14d+16:54:03.993 IDENTIFY DEVICE
ef 03 45 00 00 00 a0 00 14d+16:54:03.990 SET FEATURES [Set transfer mode]
27 00 00 00 00 00 e0 00 14d+16:54:03.990 READ NATIVE MAX ADDRESS EXT [OBS-ACS-3]
...
...
SMART Self-test log structure revision number 1
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
# 1 Short offline Completed: read failure 10% 6410 1468496680
...
...

MySQL Log

1
2
3
4
5
6
7
8
9
10
2018-01-08  9:38:25 140666168350528 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-01-08 9:38:25 140666168350528 [Note] InnoDB: Completed initialization of buffer pool
2018-01-08 9:38:32 140666168350528 [ERROR] InnoDB: Tried to read 1048576 bytes at offset 2097152. Was only able to read 163840.
2018-01-08 09:38:32 7fef64ff1740 InnoDB: Operating system error number 5 in a file operation.
InnoDB: Error number 5 means 'Input/output error'.
InnoDB: Some operating system error numbers are described at
InnoDB: http://dev.mysql.com/doc/refman/5.6/en/operating-system-error-codes.html
InnoDB: Operation read to file /tmp/mariadb-10.1.14/storage/xtradb/os/os0file.cc and at line 3160
2018-01-08 9:38:32 140666168350528 [ERROR] InnoDB: File (unknown): 'read' returned OS error 205. Cannot continue operation
180108 09:38:32 mysqld_safe mysqld from pid file /usr/local/data/mysql/data/mysqld.pid ended

Conclusion

‘Input/output error’ most likely means harddisk error!
Please backup ASAP!


Go Programming Language

GoLang

Installation

1
2
3
4
5
6
# download: https://golang.org/doc/install

# set Path
export PATH=$PATH:/usr/local/go/bin
export GOROOT=$HOME/go1.X
export PATH=$PATH:$GOROOT/bin

Source code

1
2
3
4
5
6
7
package main

import "fmt"

func main() {
fmt.Printf("hello, world\n")
}

Compile

1
2
cd $HOME/go/src/hello
go build

Execute

1
2
./hello
# output: hello, world

Serverless JAMstack

JAMstack

JAMstack

Javascript, APIs, Markup

Markup Generator

  • JekyII - jekyllrb.com
  • Hugo - gohugo.io
  • Hexo - hexo.io
  • Octopress - octopress.org
  • Gatsby - github.com/gatsbyjs
  • Pelican - getpelican.com
  • Brunch - brunch.io
  • Metalsmith - metalsmith.io
  • Middleman - middlemanapp.com
  • Nuxt - nuxtjs.org
  • StaticGen - staticgen.com

JavaScript

Do something to connect your APIs.

APIs

  • Contentful
  • Netlify
  • Algolia

Reference

https://jamstack.org/