Friday, December 28, 2018

Install miniconda to Rasperry pi (rasbian)

miniconda.md

Install miniconda to Rasperry pi (rasbian)

On installation everything on deafault execpt change directory to /home/pi/miniconda3

Add following line to export PATH="/home/pi/miniconda3/bin:$PATH"

so it would be like this

wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-armv7l.sh sudo /bin/bash Miniconda3-latest-Linux-armv7l.sh sudo vi /home/pi/.bashrc sudo reboot -h now

test installation with

conda python --version

If conda update fails, it is probably for the rights

sudo chown -R pi miniconda3

Control VirtualBox virtual machines on terminal

VirtualBoxTerminal.md

Command line virtual box controlling

List running virtual machines

"<path to VBoxManage.exe>" list runningvms for example C:\Program Files\Oracle\VirtualBox\vboxmanage list runningvms

List all virtual machines

"<path to VBoxManage.exe>" list vms for example C:\Program Files\Oracle\VirtualBox\vboxmanage list vms

Start virtual machine

"<path to VBoxManage.exe>" startvm "<virtual machine name>" --type headless for example "C:\Program Files\Oracle\VirtualBox\VBoxManage" startvm "<vm name>" --type headless

Shutdown

"<path to VBoxManage.exe>" controlvm "<virtual machine name>" poweroff for example "C:\Program Files\Oracle\VirtualBox\vboxmanage" controlvm "testmachine" poweroff

restore to snapshot

"<path to VBoxManage.exe>" snapshot "<virtual machine name>" restore <shapshot name> for example "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" snapshot "testmachine" restore Initial

Simple workflow to use VirtualBox virtual machine on testing

Virtualboxbuild.md

Simple workflow to use VirtualBox virtual machine on testing

If you want to use VirtualBox virtualmachine for testing you can easily script it like this

  1. Restore virtual Machine to wanted snapshot
  2. Start virtual machine on headless mode
  3. Excute your process
  4. Power off virtual machine
  5. Restore to snapshot

so it would be something like this

"<path to VBoxManage.exe>" snapshot "<virtual machine name>" restore <shapshot name> "<path to VBoxManage.exe>" startvm "<virtual machine name>" -type headless restore <shapshot name> "<path to VBoxManage.exe>" controlvm "<virtual machine name>" poweroff "<path to VBoxManage.exe>" snapshot "<virtual machine name>" restore <shapshot name>

for example

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" snapshot "testmachine" restore Initial "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm "testmachine" -type headless "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "testmachine" poweroff "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" snapshot "testmachine" restore Initial

Autologon and autostart VirtualBox virtual machines on windows 10

VirtualBoxw10.md

VirtualBox machines autostart on windows 10

Open start up directory by typing shell:startup on Run dialog (win+R)

Create shortcuts there. The target is ""startvm "virtual machine name" -type headless

for example

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm "testmachine" -type headless

Download Autologon for Windows from Micrsoft sysinternals.

Autologon is easy enough to use. Just run autologon.exe, fill in the dialog, and hit Enable

SSH on rasperry pi

rasperry.md

SSH on rasperry pie

Enable ssh on rasperry pie

For the first time

Open terminal

  1. Type raspi-config
  2. Choose Interfacing Options
  3. Select SSH
  4. Choose Yes
  5. Select Ok
  6. Choose Finish

After the first time you can enable and disable if by terminal type following

sudo systemctl enable ssh sudo systemctl start ssh

Use ssh key on login

On client

Generate key

ssh-keygen

check the key

cat ~/.ssh/id_rsa.pub ssh-rsa <REALLY LONG STRING OF RANDOM CHARACTERS> user@host

copy key to rasperry

ssh-copy-id <USERNAME>@<IP-ADDRESS>

Copy files with scp

copy from rasperry to local

scp pi@192.0.0.0:<path to file> . scp pi@192.0.0.0:/home/pi/history.txt .

copy to Rasperry pi

scp <path to local file> pi@192.0.0.0:<path to remote> scp history.txt pi@192.0.0.0:/home/pi/

Simple workflow for using git from Rasperry pi

Simple workflow for using git from Rasperry pi


Initialize rasperry pi

Open Disk Utility. Erase the USB drive, format as MS-DOS (FAT) and call the volume GITPI

Open the Terminal and type ssh pi@192.0.0.0
update package information, upgrade packages and reboot rasperry

sudo apt-get update
sudo apt-get upgrade
sudo reboot 

Install git

sudo apt-get install wget git-core 

Make usb-drive permanent 


Create directory as mount point (mkdir usbgit)
Check information (sudo blkid)
Add line /dev/sda1 /home/pi/usbdrv vfat uid=pi,gid=pi,umask=0022,sync,auto,nosuid,rw,nouser 0 0 to /etc/fstab with editor (for example vi)
reboot

for example

mkdir usbgit

sudo blkid /
dev/sda1: LABEL="GITPI" UUID="4444-1111" TYPE="vfat" PARTUUID="oaoaoaoaoa-01"
sudo vi /etc/fstab 

in vi add line from under
 /dev/sda1 /home/pi/usbgit vfat uid=pi,gid=pi,umask=0022,sync,auto,nosuid,rw,nouser 0 0 

sudo reboot 

Test that you can write to usb

touch /home/pi/usbgit/test.txt 

Create repo 

Take ssh connection

ssh pi@192.0.0.0 pi@192.0.0.0's password: cd usbgit/ mkdir <new folder>.git cd <new folder>.git git init --bare 

 On client machine

mkdir <new folder>
cd <new folder>
git init
git remote add pi pi@192.0.0.0:/home/pi/usbgit/<new folder>.git
touch .gitignore
git add .
git commit -m "initial commit"
git push pi master 

create local branch on client


git checkout -b <new branch>
# changes git add .
git commit -m "changes" 


Push local branch to remote 


git push -u pi 

Merge branch to master 


git checkout -b <new branch> git pull git checkout master git pull pi master git merge --no-ff --no-commit  git status git commit -m 'Merge to master' git push pi master git remote show pi 

Deleting local branches in Git

 git branch -d <barnch name>

 Deleting remote branches in Git 

 git push pi --delete <branch name>

Saturday, November 10, 2018

Simple VI editor workflow

On terminal start editing by writing vi <filename>
for example
vi readme.txt
Move cursor to place you want to edit with arrow keys.
Press i key to start editing.
Press ESC to edn the editing.
Press a colon (:) to change to command mode. Cursor moves to bottom of the screen.
On command mmode
  • w is save
  • q is quit
So save and quit is wq
To quit is without saving is q!
Saving readonly files is
:w !sudo tee %
Afterwards exit with :q!