сряда, ноември 21, 2018

Google Play Services 10002 RESULT_SIGN_IN_FAILED: add development signing certificate for new machine

If we change our development machine with a new one and install Android Studio, we'll have a new debug.keystore created by the new Android Studio installation.

Our apps run directly from the IDE during development will no longer be signed with key registered with Google Play Services.

This is not a problem if the app doesn't use Google Play Services like Sign-in, Leaderboards or Achievements. But if it does, they will no longer work and we may get the 10002  RESULT_SIGN_IN_FAILED error.

There are two possible resolutions to this problem.

1. Copy and replace the debug keystore from your previous computer to the new one. I haven't tried that one, but it should work. For Linux/Mac machines it's located in ~/.android/debug.keystore

2. The second solution is to get the SHA1 fingerprint of our new debug.keystore and add it to the Google API console.
keytool -list -keystore path-to-debug-keystore
Then we copy the SHA1 fingerprint from the previous step and go to https://console.developers.google.com/apis/credentials and select our application project. Click on the Credentials link on the menu and create new OAuth Client ID credentials. Following the steps, we paste the SHA1 fingerprint, name the new client, save and everything should be ok.

четвъртък, септември 20, 2018

Enable SHIFT+Numpad keys for navigation on Ubuntu 18.04

setxkbmap -option 'numpad:microsoft'

Another often helpful shortcut Ctrl+Alt+Arrow to navigate in source files after peeking into a function and going back to the previous.

On Ubuntu 18.04 by default these shortcuts are taken by the system. To free them up for use by editors, use the following:

gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-left "[]"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-right "[]"

четвъртък, септември 13, 2018

Safe way to cleanup Ubuntu boot partition

First check your kernel version, so you won't delete the in-use kernel image, running:
uname -r
Now run this command for a list of installed kernels:
dpkg --list 'linux-image*' | grep ^ii
and delete the kernels you don't want/need anymore by running this:
sudo apt-get remove linux-image-VERSION
Replace VERSION with the version of the kernel you want to remove.
When you're done removing the older kernels, you can run this to remove ever packages you won't need anymore:
sudo apt-get autoremove
And finally you can run this to update grub kernel list:
sudo update-grub

This is a direct copied response from askubuntu.com for preservation purposes, as things on the internet often disappear unexpectedly (and forever).

понеделник, юли 09, 2018

Custom type holding string OR int implementing the Marshaller interfaces for automatic marshal/unmarshal by the standard JSON library

package main

import (

type stringOrInt struct {
 Int    int
 String string

func (s *stringOrInt) MarshalJSON() ([]byte, error) {
 if s.Int != 0 {
  return []byte(strconv.Itoa(s.Int)), nil
 if s.String != "" {
  return []byte(fmt.Sprintf(`"%s"`, s.String)), nil

 return nil, nil

func (s *stringOrInt) UnmarshalJSON(data []byte) error {
 if len(data) == 0 {
  return nil

 if data[0] == '"' {
  s.String = string(data[1 : len(data)-1])
  return nil

 i64, err := strconv.ParseInt(string(data), 10, 64)
 if err != nil {
  return err
 s.Int = int(i64)
 return nil

type envelope struct {
 ResourceOwnerID *stringOrInt `json:"resource_owner_id,omitempty"`

func main() {
 e1 := envelope{&stringOrInt{Int: 42}}
 e2 := envelope{&stringOrInt{String: "4-4-2"}}
 e3 := envelope{&stringOrInt{}}

 j1 := toJSON(e1)
 var e4 envelope
 err := json.Unmarshal([]byte(j1), &e4)
 if err != nil {
 fmt.Printf("Unmarshal: %+v\n", e4.ResourceOwnerID)

 j2 := toJSON(e2)
 var e5 envelope
 err = json.Unmarshal([]byte(j2), &e5)
 if err != nil {
 fmt.Printf("Unmarshal: %+v\n", e5.ResourceOwnerID)


func toJSON(v interface{}) string {
 d, _ := json.Marshal(v)
 return string(d)

сряда, юли 04, 2018

NPM/Yarn error when building docker image from nodejs project (Ubuntu Linux 16.04)

The following error may happen on Linux when building the docker images for nodejs projects with scoped private repositories.

An unexpected error occurred: Request failed \"404 Not Found\""

One way to fix it follows:

Step 1 

Edit /etc/resolv.conf and change the DNS server to one that can be seen from docker containers:

search npm-private-repo-domain.com

Step 2

sudo service systemd-resolved stop

сряда, декември 13, 2017

Cleanup disk space consumed by Docker

See the space used by Docker images, containers and volumes:
docker system df

Cleanup space used by containers:
docker system prune

Cleanup space used by volumes
docker volume prune
Total clean with force flag:
docker system prune -af