Start with Aerial Robotics

I recently was searching for courses or new skill to learn which include physics, Mathematics and Engineering together. As I feel all three makes me to understand things around the world better. I started the course in Coursera called Aerial Robotics which is taught by Mr. Vijay Kumar and Co from University of Pennsylvania.

Just reading and doing assignments is not giving me deep understanding of the concepts and many school level physics concepts which needs to be refreshed and even my Maths is going worse day by day ;).

So, today I decided to write about the concepts whatever I learn in the course and continue writing if I do some projects in Aerial Robotics. May be helpful for others too and correct me If any of my posts are not convincing.

Stay tuned.


python script to fetch rss feeds

I was just thinking about making an rss bot in telegram, and wrote a small python script which can fetch rss feeds from the feed link and prints the result with “Title” and “Link”.

import feedparser
import sys

if len(sys.argv) < 2:
print("USAGE: python <rss feed link>")

rss_url = sys.argv[1]
print("TITLE","                                                   ","LINK")

feed = feedparser.parse( rss_url )

y = len(feed[ "items" ])

for x in range(0,y):
print('\033[91m'+feed[ "items" ][x][ "title" ] + '\033[0m', "-", feed[ "items" ][x][ "link" ])

Below example shall print the feeds available in Mobilecrunch.

$ python

Newest code will be available in gist if I forget to update this blog.

systemd stuffs

[In draft stage]

This blog is a notes on systemd which I have noted down while reading a online documnet and through man pages.Will keep updating it.

socket-based activation
bus-based activation
path-based activation
device-based activation
implicit dependency mapping
instances and templates
easy security hardening
drop-ins and snippets – Override the Vanila units.

service file location:

/lib/systemd/system/ – The systemd unit files are stored.

/etc/systemd/system/ – overrides above services if the same service name.

/run/systemd/system/ – runtime units.

Unit file types:

.service – for daemons and applications.

.socket – for socket activation.





.target – system states.

.path – path based activation ‘inotify’.

.timer – manage jobs with time. cron type.

.snapshot – system current state snapshot.

.slice – Resource isolation with cgroups for users.


[Unit] Section:



Requires=: This directive lists any units upon which this unit essentially depends. If the current unit is activated, the units listed here must successfully activate as well, else this unit will fail. These units are started in parallel with the current unit by default.

Wants=: This directive is similar to Requires=, but less strict. Systemd will attempt to start any units listed here when this unit is activated. If these units are not found or fail to start, the current unit will continue to function.

BindsTo=: This directive is similar to Requires=, but also causes the current unit to stop when the associated unit terminates.

Before=: The units listed in this directive will not be started until the current unit is marked as started if they are activated at the same time.

After=: The units listed in this directive will be started before starting the current unit. This does not imply a dependency relationship and one must be established through the above directives if this is required.

Conflicts=: This can be used to list units that cannot be run at the same time as the current unit.



[Install] Section:

Only units that can be enabled will have this section.






[Service] Section:

The [Service] section is used to provide configuration that is only applicable for services.

Type: directive:

simple: exestart is the main process.

forking: exestart is the parent process which might exit by launching child process.

oneshot: wait till comeples this process, its very short term ;).

dbus: wait untill the bus name is created.

notify: notifies systemd after started successfully.

idle: This indicates that the service will not be run until all jobs are dispatched.

Additional Directives in Service:





Directives for Managing services:

ExecStart=: full path to the binary which needs to be executed.

ExecStartPre=: path to the app, to run before the main process.

ExecStartPost=: path to the app, to run after the main process created.

ExecReload=: path to the app, to reload the service.

ExecStop=: path to the app, to stop the process.

ExecStopPost=: execute after stop.

RestartSec=: time to wait before restarting the process.

Restart=: restart the process on event.

TimeoutSec=: time of waiting to declare the process is failed to start/stop.

[Socket] Section:

ListenStream=: stream socket address.

ListenDatagram=: datagram socket address.

ListenSequentialPacket=: sequential, reliable communication with max length datagrams that preserves message boundaries


Additional Directives:

Accept=: to control creating instances for each connections.

SocketUser=: root user if  left unset.

SocketGroup=: group owner of the socket,  root if unset.

SocketMode=: permissions

[Mount] Section:

What=: Takes an absolute path of a device node

Where=: The absolute path of the mount point where the resource should be mounted.

Type=: Filesystem type.

Options=: Any mount options that need to be applied. This is a comma-separated list.



TimeoutSec=: Configures the amount of time the system will wait until the mount operation is marked as failed.

[Automount] Section:



[Swap] Section:

What=: Absolute path to the location of swap space.


Options=: options sets in /etc/fstab


[Path] Section:









[Timer] Section:








Unit=: This directive is used to specify the unit that should be activated when the timer elapses. If unset, systemd will look for a .service unit with a name that matches this unit.


[Slice] Section:

Template units:

Template Specifiers:

%n: Full resulting unit name.


%p: Unit name prefix.


%i: This references the instance name, which is the identifier following the @ in the instance unit.



%c: Control group of the unit.

%u: Name of the user configured to run the unit.

%U: Name of the user, but as UID – numeric.

%H: Hostname of the running system.

%%: To insert the literal percentage.

Systemd commands:

* systemctl start <servicename>

* systemctl stop <servicename>

* systemctl restart <servicename>

* systemctl reload <servicename>

* systemctl enable <servicename>

* systemctl disable <servicename>

* systemctl list-units

* systemctl list-units –all

* systemctl list-unit-files

* journalctl

* journalctl -b #Current boot log.

* journalctl -k #Kernel messages.

* systemctl status <servicename>

* journalctl -u <servicename>

* systemctl cat <servicename>

* systemctl list-unit-files –type=target

* systemctl get-default

* systemctl set-default

* systemctl list-dependencies

* systemctl isolate

* systemctl show sshd.service -p Conflicts

Stopping or Rebooting the Server:

* systemctl poweroff #poweroff the Server

* systemctl reboot #reboot the system.

* systemctl rescue #boot to rescue mode.

Starting and Stopping Services:

* systemctl start application.service

* systemctl start applications

* systemctl stop application.service

Restarting and Reloading:

* systemctl restart application.service

* systemctl reload application.service

* systemctl reload-or-restart application.service

Enabling and Disabling services:

* systemctl enable application.service

* systemctl disable application.service

Checking the Status of services:

* systemctl status application.service

* systemctl is-active application.service

* systemctl is-enabled application.service

* systemctl is-failed application.service

* systemctl list-units –all –state=inactive

Masking and Unmasking units:

* systemctl mask application.service

* systemctl unmask application.service


* journalctl –list-boots

* journalctl –since yesterday

* journalctl _PID=<PID_NUMBER>

* man systemd.journal-fields

* journalctl -F _PID

* journalctl /usr/bin/bash


* journalctl -p err -b

0: emerg
1: alert
2: crit
3: err
4: warning
5: notice
6: info
7: debug

* journalclt –no-pager #output to stdout

* journalctl -b -u shhd -o json

* journalctl -n #display last 10 lines.

* journalctl -n 20 #display last 20 lines.

* journalctl -f #following logs.

* journalctl –disk-usage

* journalctl –vacuum-size=1G

* journalctl –vacuum-time=1years

Use serial tty as a user

Normally when we connect any boards like arduino, USB to serial converter we end up running applications with sudo. But sometimes we need to run some applications inside scripts which uses these tty’s or simply people think why always I need to run with sudo (for those who comfortable clicking on Application icons and using the App).

The solution to use these tty’s with user permissions is solved bt adding user to dialout and tty group. As mentioned below.

sudo usermod -a -G tty yourUserName

sudo usermod -a -G dialout yourUserName

Now you can run tty based applications with your username without sudo :).  Reference


Extract mp3 from youtube-dl

There is a famous command line tool called youtube-dl to download videos from youtube, and its an opensource project written in python and available for Linux, windows and OSX platforms.

In Linux, you can install the tool using:

$ sudo pip install –upgrade youtube-dl

To download a video from a link:

$ youtube-dl <Your Video link>

Example: youtube-dl

It will get donwloaded in $PWD.

To download mp3 from a link:

$ youtube-dl –extract-audio –audio-format mp3 <Your Video Link>

Example: youtube-dl –extract-audio –audio-format mp3

It will get downloaded in $PWD.

Do “youtube-dl -h” for more help on formats and other features.


Download audio from soundcloud through command line

Like youtube-dl there is a command line tool called scdl, which is written in python based on GPLV2 license and works on Linux, windows and OSX.

To install in linux, execute below command:

$ pip install scdl

To download a single song:

$scdl -l <Sound cloud link to the song>

Example: scdl -l scdl -l

It will download and store in $PWD

Do “scdl -h” to know other options like download complete album, user liked videos etc.



Arch Linux: Remove downloaded packages cache and clear memory

My rootfs is very small in size (30 GB), and I am running Arch Linux from past two years and constantly upgrade the new releases and packages. At some point of time my rootfs become full and I couldn’t able to install anything new (not even upgrade the system). When I looked at my rootfs, like which directory is consuming maximum space, found /var/cache/pacman/pkg holds 12 GB of my memory. And it all contains compressed packages which is downloaded when I upgrade my system. All those packages you might not need often, so you can remove all those packages safely using below command.

pacman -Sc

Now I have got my 12 GB free space back. 🙂

For more info Link