Search in this blog

Thursday, August 2, 2018

Disable encryption for Ubuntu remote access VNC server

How to disable encryption for Ubuntu's built-in VNC server.
$ sudo apt-get -y install dconf-tools
$ sudo dconf write /org/gnome/desktop/remote-access/require-encryption false
This can be useful if any third-party VNC client can not establish encrypted connection with Ubuntu VNC server. Not secure option.

System startup time in Ubuntu

How to check how long does it takes for Ubuntu to start:
$ systemd-analyze
Startup finished in 5.233s (kernel) + 5.342s (userspace) = 10.575s

Usage examples of find command to search and remove files

Check current directory for *.log files larger than 1Mb:
$ find . -maxdepth 1 -name '*.log' -type f -size +1M
./parallels.log
Check directory tree up to 5 enclosed folders for *.log files larger than 1Mb, and show their size:
$ find . -maxdepth 5 -name '*.log' -type f -size +1M -exec du -h {} \;
1.4M ./parallels.log
 Check directory tree up to 5 enclosed folders for *.log files larger than 1Mb, and remove them forcibly:
find . -maxdepth 5 -name '*.log' -type f -size +1M -exec rm -f {} \;
Or same using the for loop:
$ for i in $(sudo find ./ -type f -name '*.log'); do
       rm -f $i
  done

Wednesday, July 5, 2017

if...elif...else in Python


That’s the difference in Python between an if...elif...else and a series of ifs:
if a:
    do this
elif b:
    do that
elif c:
    do something else
else:
    print "none of the above"
is equivalent to (exactly the same as) this:
if a:
    do this
if (not a) and b:
    do that
if (not a) and (not b) and c:
    do something else
if (not a) and (not b) and (not c):
    print "none of the above"
As you can see, the elif...else notation allows you to write the same logic (the same control flow) without repeating the a condition over and over again.

Copied from here: https://www.codecademy.com/en/forum_questions/51684a3d4ce76309b4001b9c

Thursday, June 22, 2017

Tag and release last updates on repository to pypi

Tag and release last updates on repository to pypi.

At first GPG key pair should be created. Look for previous post about it.

Checkout to required branch:
$ git checkout master
Create signed version tag:
$ git tag -s 0.1.13
Verify tag that was created:
$ git tag -v 0.1.13
Check list of git remotes:
$ git remote
gerrit
origin
Push tag to gerrit remote:
$ git push gerrit 0.1.13

Generate GPG key pair for git commits

Use command:
$ gpg --gen-key
Select default options (or specify other).

  • Select what kind of key you want: (1) RSA and RSA (default).
  • RSA keys may be between 1024 and 4096 bits long.
  • Please specify how long the key should be valid: 0 = key does not expire.

Then enter your real name, email address and comment.
Then we need to generate a lot of random bytes for entropy. Load computer with disk operations to provide random number generator a better chance to gain enough entropy.
Wait while public and secret keys will be created.

List keys:
$ gpg --list-keys
/home/username/.gnupg/pubring.gpg
-----------------------------------
pub   2048R/9DA4A3D1 
...

Configure the key before using it for single repository, or globally if you are going to use the same key for every repository:
$ git config user.signingkey 9DA4A3D1 
$ git config --global user.signingkey 9DA4A3D1

Done.

Wednesday, March 22, 2017

How to get IP address of specified interface in bash scripting?

There is a one-line pipeline of commands to get IP address assigned to a specified interface. For example to eth0:
ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'