• Today I learned: Raspbian OS is almost always 32 bit because of the backward compatibility reasons.
    • Ubuntu 20.04 has 64 bit edition for raspberry pi but for stability it’s recommended to use raspbian. All these opinions are for server, rather than desktop OS with desktop environment. There are people using ubuntu just fine.
  • Get raspberry pi heat from command line /opt/vc/bin/vcgencmd measure_temp
  • Mount windows net share folders in raspberry pi
    • First share your stuff from Windows
    • Instal CIFS protocol utils sudo apt-get install cifs-utils
    • Mount network drive to local: sudo mount.cifs // /mnt/shared_from_win -o user=windows_username
    • Enable write too:
    • Optional run coder-server and open these network folders.
  • coder-server can not install vim extension which is unleavable so I found this hack on github issue. Instead of waiting for coder-server folks to put the most recent vscode into the release (their last release was on 18th of dec so it’s been more than a month). Instead you can download an older version of the vim plugin and install via vsix from this address: https://open-vsx.org/api/vscodevim/vim/1.16.0/file/vscodevim.vim-1.16.0.vsix
    • wget https://open-vsx.org/api/vscodevim/vim/1.16.0/file/vscodevim.vim-1.16.0.vsix
  • Output sqlite data to csv
    >sqlite3 c:/sqlite/chinook.db
    sqlite> .headers on
    sqlite> .mode csv
    sqlite> .output data.csv
    sqlite> SELECT customerid,
    ...>        firstname,
    ...>        lastname,
    ...>        company
    ...>   FROM customers;
    sqlite> .quit
  • port forwarding error and how to kill the program which is binding a specific port
    bind: Address already in use
    channel_setup_fwd_listener_tcpip: cannot listen to port: $PORT
    Could not request local forwarding.

This will solve the problem:

lsof -ti:$PORT | xargs kill -9
ssh -fNL$PORT:localhost:58846 [email protected]_host
  • pyautoit doesn’t work on WSL Linux :/
Traceback (most recent call last):
  File "bot.py", line 20, in <module>
    import autoit
  File "env/lib/python3.6/site-packages/autoit/__init__.py", line 6, in <module>
    from .autoit import options, properties, commands
  File "env/lib/python3.6/site-packages/autoit/autoit.py", line 7, in <module>
    from ctypes.wintypes import *
  File "/usr/lib/python3.6/ctypes/wintypes.py", line 20, in <module>
    class VARIANT_BOOL(ctypes._SimpleCData):
ValueError: _type_ 'v' not supported
  • Get memory size of a python object (eg. dict, list etc) in bytes
    >>> import sys
    >>> d = {1:2}
    >>> sys.getsizeof(d)

Hint: The size is usually smaller than the json file size.

  • pylance is a nice program from Microsoft as tabnine alternative for better python coding assisstant.
  • Use .mode column to pretty print the columns in sqlite3 commad line output with better formatting.
  • Python3 scripts can still cause encoding errors when it’s run from cron. So your perfectly fine running script may break during being run as cron job. In this case, even though you have encoding as utf-8, you should have this too before running the script:
    export PYTHONIOENCODING="utf-8"
    export LC_CTYPE="en_US.UTF-8"

In crontab -e you can prepend this


Raspberry Pi, Windows and External HDD humps

Mount external HDD to raspberry pi


sudo blkid
sudo mount /dev/sda2 /mnt/filmhdd

Share raspberry pi drive to Windows 10 as network folder


sudo fdisk -l

sudo mkdir /media/USBHDD
sudo chmod -R 777 /media/USBHDD
sudo mount -t auto /dev/sda1 /media/USBHDD
sudo apt-get install samba samba-common-bin
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old
sudo nano /etc/samba/smb.conf

Add this:

sudo service smbd restart

If there is any problem, check out the samba logs:

cat  /var/log/samba/log.smbd

Mount a windows 10’s network shared folder in raspberry pi

We need to use CIFS for this. So we need to install cifs-utils in pi and we should use mount.cifs unlike previous mounts.

sudo apt-get install cifs-utils
mkdir ~/mnt/dev
sudo mount.cifs // /mnt/dev -o username=hakanucom,uid=$(id -u),gid=$(id -g),sec=ntlmv2


This creates a a temporary link. It will be lost when you reboot. For persistent shares, append a line to the /etc/fstab file in this format:

sudo leafpad /etc/fstab

// /home/pi/LANPC/DEV cifs username=Myname,password=Mypassword,iocharset-utf8,sec=ntlm 0 0

# If you reboot the Rpi3 and find the share directories empty, issue this command:
sudo mount -a;

Which sharing method to use

  1. Use Windows and want to share files with family members? SMB
  2. Have an Apple household instead? AFP
  3. Want to share files between two Linux-based desktops? SMB
  4. Want an ongoing connection between a Linux-based desktop and server? NFS
  5. Want something that really doesn’t care what OS you prefer? FTP
  6. Need security when you’re away from home? SFTP
  7. Stream music and videos to a TV? DLNA