Install Razberry on Raspberry PI

razberry

Install Razberry as it is shown on the picture above.

Software  is installed with the command below:

wget -q -O - razberry.z-wave.me/install | sudo bash

Find in installation log user ID and password, they can be used to login remotely using https://find.w-wave.me

Check if service is running with

sudo service zbw_connect status

More information on Razberry project can be found here: http://razberry.z-wave.me

DONE

, , , ,

Leave a comment

Toast message for Xamarin Forms

toastdemo_androidtoastdemo_ios

Quick and easy solution for toast messages in Xamarin Forms, it supports iOS and Android platforms. Toast message provides simple feedback in a small popup (which is disappearing in some seconds) like on the screenshots on the left (Android) and the right (iOS) sides.


Read the rest of this entry »

, , , , , , , , , ,

3 Comments

Step by step tutorial: how to setup new Raspberry PI from command line

Writing image

Connect RPI to Wi-Fi

  • Check wireless connection with “sudo iwlist wlan0 scan”
  • Setup wireless with nano “sudo nano /etc/wpa_supplicant/wpa_supplicant.conf”
  • Add the config below to wpa_supplicant.conf in the end of the file
network={
    ssid="The_ESSID_from_earlier"
    psk="Your_wifi_password"
}
  • do “sudo ifdown wlan0” then “sudo ifup wlan0”
  • check address with ifconfig

Upgrade RPI to the latest packages, install mc

  • do “sudo apt update”
  • do “sudo apt upgrade”
  • do “sudo apt install mc”
  • set default editor to mcedit “sudo update-alternatives –set editor /usr/bin/mcedit”

Add your own user, configure sudoers, change password of pi

  • add new user with a command “sudo adduser youruser”
  • add the user to sudoers with visudo “sudo visudo”
  • add the following line in the end “youruser ALL=(ALL) NOPASSWD: ALL”
  • change password of pi user “passwd”
  • reboot your RPI with “sudo rpi”

Setup firewall

  • Install ufw with “sudo apt install ufw”
  • Allow minimum ssh ports with “sudo ufw allow 22/tcp”
  • Allow all other port you are going to use, i.e web “sudo ufw allow 80/tcp”
  • Enable ufw “sudo ufw enable”
  • Check the status “sudo ufw status”

Login with your user, fix locales

if you have the issue “warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)”, you can solve it with the command “sudo dpkg-reconfigure locales”, select en_US.UTF-8 as default

Make a backup

  • Make backup with ApplePI-Baker.app downloaded in the beginning

DONE

, , , ,

Leave a comment

Reinstall formula with brew from scratch

Uninstall

brew uninstall --force formula_name

Clear versions & cache

brew cleanup --force -s formula_name

Remove dead symbolic links

brew prune formula_name

Install again

brew install formula_name

Enjoy 🙂

, ,

Leave a comment

Delete certificates from System Roots in Keychain Access on Mac

Before you start deleting certificates from System Roots in your Keychain Access, make sure that you know what you are doing as you can harm your mac if you will delete some essential certificates.

You have been warned 🙂

1. Reboot mac in recovery mode (Hold cmd+R) during restart

2. Start terminal and switch off System Integrity Protection running the command

csrutil disable

3. Reboot in normal mode

4. Start keychain access and find the certificates you want to delete, check its name or unique fingerprint (Right click -> Get info -> Common name or SHA1)

5. Use command line below to delete the certificate using common name:

sudo security delete-certificate -c Common-Name /System/Library/Keychains/SystemRootCertificates.keychain

Or command line below if you are using SHA1 (delete all the spaces in SHA1 fingerprint before running the command)

sudo security delete-certificate -Z SHA1-fingerprint /System/Library/Keychains/SystemRootCertificates.keychain

6. Reboot your mac in recovery mode again (Hold cmd+R)

7. Start terminal and switch on System Integrity Protection running the command

csrutil enable

8. Reboot in normal mode

, , , , , , , , ,

Leave a comment

Localization for GOLANG

I created and published small package to be used for localization of go applications, you can find it here https://github.com/bykovme/gotrans

Installation

Install the package with the command

go get github.com/bykovme/gotrans

Prepare translation files

JSON files should use following format as in the example below:

{
    "hello_world":"Hello World",
    "find_more":"Find more information about the project on the website %s"
}

JSON file name should use standard language code or language-country code supported by browsers, if you are developing web app. At least one file with English locale should be in the localization folder with the name “en.json”.

Quick documentation

There are just 3 functions in the package

InitLocales(path string)

Use the relative or absolute path to set the folder where all the JSON files with translations are located. Make sure that all the files with translations have extension “.json”

Tr(lang string, key string) string

Get translation value by the language & key

DetectLanguage(acceptLanguage string) string

This function will be useful when you are creating web application, it detects the language from HTTP header Accept-Language, check the usage of the function in the example below

Example of using gotrans package

The same example is located within the package here

package main

import (
    "fmt"
    "net/http"

    "github.com/bykovme/gotrans"
)

func handler(w http.ResponseWriter, r *http.Request) {
    lang := gotrans.DetectLanguage(r.Header.Get("Accept-Language"))
    fmt.Fprintf(w, "<html><head><title> %s </title></head><body>", gotrans.Tr(lang, "hello_world"))
    fmt.Fprintf(w, "<h2> %s </h2>", gotrans.Tr(lang, "hello_world"))
    githubLink := "https://github.com/bykovme/gotrans"
    link := fmt.Sprintf(`<a href="%s">%s</a>`, githubLink, githubLink)
    fmt.Fprintf(w, gotrans.Tr(lang, "find_more"), link)
    fmt.Fprint(w, "</body></html>")
}

func main() {
    err := gotrans.InitLocales("langs")
    if err != nil {
        panic(err)
    }

    http.HandleFunc("/", handler)
    http.ListenAndServe(":3000", nil)
}

Behaviour

If the key is not found in the localization file, it will try to find the same key in English localization (“en.json”), if the key is not found there as well, the key will be returned instead of value.

, , , , , ,

Leave a comment

How to use https on Google App Engine for all requests for custom domain

Before use the settings below, make sure that you uploaded and assigned appropriate SSL certificate to your app project.

Forcing GAE to use https is very easy, just need to mention the option “secure” with value “always” in “app.yaml” file (other options are “optional” for using both http & https (default behavior) and “never” for using http only), the example below in for golang app, the same approach is used for other languages.

application: your-app-here
version: 1
runtime: go
api_version: go1

- url: /.*
  script: _go_app
  secure: always

, , , ,

Leave a comment