Create first project on Arduino

To start programming Arduino download official Arduino IDE software from the site: https://www.arduino.cc/en/Main/Software

If you use Arduino Nano, you need to install CH341 driver. Next connect Arduino to PC via Mini-USB cable:

Run Arduino IDE, go to Tools -> Board and set correct Arduino model, processor and serial port:

Correct port you can see in Device Manager in the section “Ports (COM & LPT)”:

If all is OK you can go to Tools -> Get Board Info and watch information about your Arduino:

Now let’s write first program on Arduino which will blink onboard led indicator. Arduino has 14 digital PIN for digital devices and 8 analog PIN for analog devices. Our led indicator connected to 13 digital pin.

In function setup() let’s say Arduino that 13 digital PIN will work in output mode:

void setup() {
  pinMode(13,1);
}

All commands in loop() function Arduino will execute in a loop. Command digitalWrite(13,1) activates 13 PIN, command digitalWrite(13,0) similarly deactivate 13 PIN on Arduino.
Command delay(1000) set delay in milliseconds between commands:

void loop() {
  digitalWrite(13,1);
  delay(1000);
  digitalWrite(13,0);
  delay(1000);
}

Next let’s compile our first program and write it to Arduino controller:

That’s all. Our first Arduino project is done. 😉

Install Gitea Git Service on Ubuntu 18.04

Gitea is a free, open source and self-hosted version control system alternative to GitHub and GitLab. It is simple, easy, robuts, scalable and a great alternative to other git services. All source code is available under the MIT License on GitHub. Gitea has low minimal requirements (1 CPU core and 1GB RAM), so it can run on an inexpensive Raspberry Pi.

You can also compile Gitea for Windows, macOS, Linux, ARM, etc. Gitea provides lots of features such as, Low resource usage, Multiple database support, free and open source, Multiple OS support, etc.

In this tutorial, we will learn how to install and configure Gitea Git Service on Ubuntu 18.04 server.

Official git repository of Gitea: https://github.com/go-gitea/gitea/

First of all install Ubuntu 18.04. on Your virtual or physical server. After that update and upgrade your system to latest version:

sudo apt-get update
sudo apt-get upgrade

First, you will need to download the latest version of Gitea binary from Git repository. All versions of Gitea You can see here: https://github.com/go-gitea/gitea/releases/. You can download it with the following command:

wget https://github.com/go-gitea/gitea/releases/download/v1.10.3/gitea-1.10.3-linux-amd64

Next, copy the downloaded file to /usr/local/bin/ directory and give necessary permissions:

cp gitea-1.10.3-linux-amd64 /usr/local/bin/gitea
chmod 755 /usr/local/bin/gitea

Next, create a system user for Gitea with the following command:

adduser --system --shell /bin/bash --group  --disabled-password --home /home/gitea gitea

Next, create a directory structure for Gitea with the following command:

mkdir -p /etc/gitea /var/lib/gitea/{custom,data,indexers,public,log}
chown gitea:gitea /etc/gitea /var/lib/gitea/{custom,data,indexers,public,log}
chmod 750 /var/lib/gitea/{data,indexers,log}
chmod 770 /etc/gitea

Create Systemd Service file for Gitea

Next, you will need to create a systemd service file to manage Gitea service. You can create it with the following command:

nano /etc/systemd/system/gitea.service

Add the following lines:

[Unit]
Description=Gitea
After=syslog.target
After=network.target
After=mysql.service

[Service]
RestartSec=2s
Type=simple
User=root
Group=root
WorkingDirectory=/var/lib/gitea/
ExecStart=/usr/local/bin/gitea web -c /etc/gitea/app.ini
Restart=always
Environment=USER=root HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea

[Install]
WantedBy=multi-user.target

Save and close the file. Then, reload systemd and start Gitea service with the following command:

systemctl start gitea

You can check the status of Gitea service with the following command:

systemctl status gitea

Next, enable Gitea service to start at boot time with the following command:

systemctl enable gitea

Allow SSH root login on Debian and Ubuntu Linux

By default Ubuntu 18.04 installation comes with unset root password. To set root password open up terminal and execute the following linux command:

$ sudo passwd
[sudo] password for user: 
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

Edit SSH configuration file: /etc/ssh/sshd_config and set property PermitRootLogin to yes:

Save configuration file and restart ssh service by command:

sudo service ssh restart

To restart SSH on Debian you can use command:

systemctl restart ssh.service

Gitlab – create and restore backup

To create backup enter command:

sudo gitlab-rake gitlab:backup:create

First we need to make sure that the backup tar file is in the backup directory described in the gitlab.rb configuration (Default is /var/opt/gitlab/backups). Next, we need gitlab running for restoring backup on ominbus installations. If it’s not up, start with,

sudo gitlab-ctl start

and we need to have services that are connected to database in stopped state,

sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq

Copy files from backup folder (/var/opt/gitlab/backups) to external hard drive, also copy files:

/etc/gitlab/gitlab-secrets.json
/etc/gitlab/gitlab.rb

Now execute the following command to restore the backup on server,

sudo gitlab-rake gitlab:backup:restore BACKUP=1393157476_2018_03_11_9.1.0

here, 1393157476_2018_03_11_9.1.0 is the name of the backup file that will be restored. Once the backup has been restored, we need to restart the gitlab services,

sudo gitlab-ctl restart

We now have successfully restored gitlab from the backup file.

Turn off clamav for email in VestaCP

You should edit /etc/exim4/exim.conf

#CLAMD =  yes
CLAMD =  no

edit /usr/local/vesta/conf/vesta.conf and comment / remove clamav

#ANTIVIRUS_SYSTEM='clamav'
ANTIVIRUS_SYSTEM=''

than disable and stop the service

systemctl disable clamd
systemctl stop clamd
systemctl restart exim

Test exim (send and receive email)
watch your log

How to install multiple PHP versions on VestaCP

First download and start manager php from Github:

git clone https://github.com/petranikin/mgrvphp.git
cd mgrvphp
bash mgrvphp

Then enter version of PHP You need to install (remember that you need to enter fool version: 7.1.4). All versions of PHP You can see on site: http://php.net/releases

Install packages and dependencies: Yes

Create links in /usr/bin : Yes

Create template in VestaCP: Yes

Then wait when script install PHP on Your server (it took me more than 30 minutes)

Once the installation is complete, you can go to the panel to install the desired template:

How to check PHP version on server and site?

Create the file phpinfo.php. Open it with a text editor and enter the following:

‹?php
phpinfo();
?›

Upload the file to the root of the site → open the file in the browser and look at the installed version of php:

Best php open source projects

1. Laravel

This is the best php-framework for new projects, web-sites, internet stores and other network projects.

The GitHub page of Laravel from where you can download and see the project code is: https://github.com/laravel/laravel

2. Symfony

Another PHP framework for web applications is Symfony. It is used by thousands of web applications (including BlaBlaCar.com and Spotify.com) and most of the popular PHP projects (including Drupal and Magento).GitHub Stars: 17.8k+

The GitHub page of Symfony from where you can download and see the project code is: https://github.com/symfony/symfony

3. Composer

Composer helps you declare, manage, and install dependencies of PHP projects.

GitHub Stars: 14.9k+

The GitHub page of Composer from where you can download and see the project code is: https://github.com/composer/composer

4. PHPMailer

PHPMailer is the best php library for sending email. Supports many mail servers including Gmail.

The GitHub page of PHPMailer from where you can download and see the project code is: https://github.com/PHPMailer/PHPMailer

How to view information about ONU on BDCOM OLT

I’ll give you an example of viewing information about ONT (ONU) on EPON OLT BDCOM P3310C, on other models is essentially the same.

Connect to OLT and go into configuration mode:

enable
config

To view the ONU list, use the commands:

show epon onu-information
show epon active-onu
show epon inactive-onu

To view all ONU MAC addresses on interface use command:

show epon onu-information interface EPON 0/1

Example of viewing clients routers MAC addresses on a port or ONU:

show mac address-table interface EPON0/1
show mac address-table interface EPON0/1:5
show mac address-table brief

Viewing the optical power of all ONUs on interface and a specific ONU:

show epon optical-transceiver-diagnosis interface EPON 0/1
show epon interface ePON 0/1:4 onu ctc optical-transceiver-diagnosis

View ONU models and firmware versions:

show epon onu-software-version
show epon onu-software-version interface EPON 0/1

View description and status of interfaces:

show interface brief

ONU ethernet port status and viewing statistics:

show epon interface epON 0/1:1 onu port 1 state
show epon interface epON 0/1:1 onu port 1 statistics
show epon interface epON 0/1:1 onu mac address-table

Also you can see in the saved and active OLT configuration which ONUs are registered:

show configuration
show running-config

ONU reboot example:

epon reboot onu interface ePON 0/1:1

How to change MAC address on Mikrotik Routerboard

By default changing MAC address of ethernet interface in Mikrotik Winbox is disabled:

But You can very simple change MAC in terminal.
In left side menu select New Terminal:

Then enter command:

/interface ethernet set ether1 mac-address=XX:XX:XX:XX:XX:XX

Where ether1 is required interface and XX:XX:XX:XX:XX:XX is new MAC address of your device.

Thats all.