How to monitor amount of data transferred over a specific port

| 6 Jan 2019
sudo iftop -i lo -f “port 8015

Django-like testrunner for python projects

| 11 Mar 2018
#!/usr/bin/env python

import argparse
import collections
import unittest
import sys


def main():
    parser = argparse.ArgumentParser(description='Django-like testrunner')
    parser.add_argument('specific_test', metavar='', type=str, nargs='?', help='Specifc test')
    parser.add_argument("--failfast", action="store_true")
    parser.add_argument("--verbosity", type=int, default=1)

    args = parser.parse_args()

    loader = unittest.TestLoader()
    all_tests = loader.discover('.', top_level_dir="./")
    suite = unittest.TestSuite()

    if args.specific_test:

        def walk_tests(tests):
            if isinstance(tests, collections.Iterable):
                for item in tests:
                    walk_tests(item)
                return
            if tests.id().startswith(args.specific_test):
                suite.addTest(tests)
            elif not str(tests).startswith("test"):
                sys.exit("Error in file %s" % tests)

        walk_tests(all_tests)
    else:
        suite.addTests(all_tests)

    result = unittest.TextTestRunner(verbosity=args.verbosity, failfast=args.failfast).run(suite)
    return result.wasSuccessful()


if __name__ == "__main__":
    if not main():
        sys.exit(1)

What command hides behind alias?

| 11 Mar 2018

To check what command is assigned to the alias use type command:

$ type gl
gl is aliased to `git log --oneline'

CPU benchmark

| 11 Mar 2018

CPU benchmark from Dell Precision 15 5510 Core-i5 i5-6440HQ

$ sysbench cpu run --time=5
sysbench 1.0.9 (using system LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time


Prime numbers limit: 10000

Initializing worker threads...

Threads started!

CPU speed:
    events per second:  1157.88

General statistics:
    total time:                          5.0008s
    total number of events:              5792

Latency (ms):
         min:                                  0.80
         avg:                                  0.86
         max:                                  3.74
         95th percentile:                      1.06
         sum:                               4998.26

Threads fairness:
    events (avg/stddev):           5792.0000/0.00
    execution time (avg/stddev):   4.9983/0.00

GUI to preview SSL certificates

| 11 Mar 2018
gcr-viewer cert.pem

List all IP addresses in a network

| 11 Mar 2018

To list ip addresses of all connected to the network devices, use this command:

nmap -sn 192.168.0.0/24

Install flashplayer in Firefox

| 16 Nov 2017

I have flashplayer installed on my system from the official Adobe repository, but Firefox for some reason does not have flash plugin installed. You can check if your browser supports flash by navigating to this url

To make Firefox aware of flashplugin, try to create a symlink here:

cd http://isflashinstalled.com/ && ln -s /usr/lib64/flash-plugin/libflashplayer.so .

Monitor process with top

| 2 Nov 2017

One liner to monitor a process with the name /wshub:

top -p "$(pgrep -f /wshub)"

Run command as a different user

| 31 Oct 2017

Command runuser allows to run a command as a different user. You must be root to be able to run that command:

sudo runuser -l vagrant -c "GH=1 env"

Monitor cpu and memory usage of the process

| 13 Oct 2017

Print every second cpu and memory usage of the process:

watch -n 1 "ps -eo pid,pcpu,pmem,args | kazy -i xnotitle -e kazy"