Dev Notes - Issue 1

August 30, 2019 Dev Notes

Contents:

  • Debugging Android device over WiFi
  • Fixing SSLHandshakeException on Android Emulator
  • Changing vector drawable color
  • Checking image transparency
  • Executing command on a file set
  • Creating a completely empty git branch
  • Copying generated SSH key to clipboard
  • Accessing Hugo server from local network
  • Measuring network speed
  • Reloading udev rules without reboot

1. Debugging Android device over WiFi

  1. Connect device via USB cable (might not be required)

    $ adb tcpip 5555
    * daemon not running; starting now at tcp:5037
    * daemon started successfully
    restarting in TCP mode port: 5555
  2. Disconnect the cable

  3. Execute this command to connect:

    $ adb connect 192.168.1.20:5555 # replace 192.168.1.20 with your device's IP
    connected to 192.168.1.20:5555
  4. To stop debugging:

    $ adb disconnect

2. Fixing SSLHandshakeException on Android Emulator

If you get the a message javax.net.ssl.SSLHandshakeException: Chain validation failed while trying to deploy your app to Android Emulator, it’s possible that it has wrong date or time settings.

  1. Open AVD Manager
  2. Locate your virtual device
  3. Click on a dropdown arrow in the end of the row
  4. Select “Cold Boot Now”

3. Changing vector drawable color

val color = Color.BLACK
val mode = PorterDuff.MODE.SRC_ATOP
drawable.setColorFilter(color, mode)

4. Checking image transparency

$ identify -format '%[channels]' ic_launcher.png
srgba # a -> notes alpha channel
$ identify -format '%A' ic_launcher.png
True # has alpha channel
$ identify -format '%[opaque]' ic_launcher.png
false # has transparent pixels

5. Executing command on a file set

$ CMD=mv
$ DIR=target_directory
$ find . -name '*.rpm' -exec $CMD {} $DIR \;

6. Creating a completely empty git branch

$ git checkout --orphan gh-pages
$ git commit --allow-empty -m "Initializing gh-pages branch"
$ git push origin/gh-pages

7. Copying generated SSH key to clipboard

$ ssh-keygen
$ sudo apt-get install xclip
$ cat ~/.ssh/id_rsa.pub | xclip -selection clipboard

8. Accessing Hugo server from local network

$ IP=192.168.1.10
$ hugo server --baseURL=http://$IP --bind=$IP

9. Measuring network speed

Install iperf:

$ sudo apt-get install iperf3

Start a server (probably on your gateway - here on localhost for simplicity):

$ iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------

Connect to the server from a client device:

$ iperf3 -c 127.0.0.1 # replace 127.0.0.1 with the server's IP
Connecting to host 127.0.0.1, port 5201
[  5] local 127.0.0.1 port 53606 connected to 127.0.0.1 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  8.11 GBytes  69.6 Gbits/sec    0   2.19 MBytes       
[  5]   1.00-2.00   sec  8.14 GBytes  69.9 Gbits/sec    0   2.19 MBytes       
[  5]   2.00-3.00   sec  8.09 GBytes  69.5 Gbits/sec    0   2.19 MBytes       
[  5]   3.00-4.00   sec  8.12 GBytes  69.7 Gbits/sec    0   2.19 MBytes       
[  5]   4.00-5.00   sec  8.06 GBytes  69.3 Gbits/sec    0   2.19 MBytes       
[  5]   5.00-6.00   sec  6.66 GBytes  57.2 Gbits/sec    0   2.19 MBytes       
[  5]   6.00-7.00   sec  6.23 GBytes  53.5 Gbits/sec    0   2.19 MBytes       
[  5]   7.00-8.00   sec  6.28 GBytes  54.0 Gbits/sec    0   2.19 MBytes       
[  5]   8.00-9.00   sec  6.26 GBytes  53.8 Gbits/sec    0   2.19 MBytes       
[  5]   9.00-10.00  sec  5.85 GBytes  50.3 Gbits/sec    0   2.19 MBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  71.8 GBytes  61.7 Gbits/sec    0             sender
[  5]   0.00-10.04  sec  71.8 GBytes  61.4 Gbits/sec                  receiver

iperf Done.

10. Reloading udev rules without reboot

# udevadm control --reload-rules && udevadm trigger
comments powered by Disqus