How to insert code in an interactive python console througth Visual Studio Code

After run your code, to edit or add new instructions is not neccesary run all your code again.
A good idea is to run a partial or section code. To do it, you must run your code as interactive mode.

You have 3 ways to do it with vscode:

1.- Task
You can create a task to run python in interactive mode.
Press Ctrl+Shift+P and type: Configure Task
Paste the following code:

{ "version": "2.0.0", "tasks": [ { "label": "Run File", "command": "python3 -i ${file}", "type": "shell", "group": { "kind": "build", "isDefault": true }, "presentation": { "reveal": "always", "focus": true } }
This task is named "Run File" and execute python3 in interactive mode. Focus options allows focus keyboard on the terminal.
To run the task press Ctrl+Shift+B

2.- Code Runner extension.
To install it, press …

How to decrypt SSL/TLS connections with wireshark

If you try to understand your SSL/TLS connections generated by your web browser like chrome, firefox or others, you must create a new variable in your .bashrc file as follows:

export SSLKEYLOGFILE="$HOME/sslkeylog.log"

To tells Wireshark where is this file, yo need specified the path in:

Edit / Preferences / Protocols / SSL / (Pre)-Master-Secret log filename.

Now, when you will call your browser from the terminal, it will generate sslkeylog.log with all private keys for each site, and wireshark would decrypt SSL/TLS traffic. Here is an example:


How to fix VirtualBox error when you try to import an ova file

If you download an ova file to import it to Virtualbox, maybe you will see the following message:

Failed to import appliance filename.ova.

Seeking within the archive failed (VERR_TAR_UNEXPECTED_EOS).

Result Code: VBOX_E_IPRT_ERROR (0x80BB0005)
Component: ApplianceWrap
Interface: IAppliance {8398f026-4add-4474-5bc3-2f9f2140b23e}

If you do it the same throught VBoxManage you will get:

# VBoxManage import filename.ova 
Progress state: VBOX_E_IPRT_ERROR
VBoxManage: error: Appliance import failed
VBoxManage: error: Seeking within the archive failed (VERR_TAR_UNEXPECTED_EOS)
VBoxManage: error: Details: code VBOX_E_IPRT_ERROR (0x80bb0005), component ApplianceWrap, interface IAppliance
VBoxManage: error: Context: "RTEXITCODE handleImportAppliance(HandlerArg*)" at line 877 of file VBoxManageAppliance.cpp

To fix it, you must extract ova content and compress again as follows:

tar xvf filename.ova
tar cvf newfilename.ova filename.ovf filename.vmdk

Also, you can import the virtual machine with double…

How to convert from LaTeX to HTML file

If you have a .tex file and you want to convert it to a .html file you can use LaTeXML.

# git clone
# sudo apt-get install libimage-size-perl libimage-magick-perl
# cd LaTeXML
# perl Makefile.PL

Warning: prerequisite Parse::RecDescent 0 not found.
Warning: prerequisite Text::Unidecode 0 not found.
Warning: prerequisite Image::Size 0 not found.
Warning: prerequisite XML::LibXSLT 1.58 not found.

To install these perl dependencies, you must use the following commands:

# sudo cpan z Parse::RecDescent
# sudo cpan z Text::Unidecode
# sudo cpan z Image::Size
# sudo cpan z XML::LibXSLT

looking for -lxslt... no
libxslt not found
Try setting LIBS and INC values on the command line
Or get libxslt and libxml2 from
If you install via RPMs, make sure you also install the -devel
RPMs, as this is where the headers (.h files) are.
No 'Makefile' created  SHLOMIF/XML-LibXSLT-1.96.tar.gz
  /usr/bin/perl Makefile.PL INSTALLDIRS=site -- NOT OK

If you h…

How to fix Low disk space on "boot"

A common issue is when /boot partition is full. You receive the following message:

"Low disk space on "boot". The volume "boot" has only 0 bytes disk space remaining"

To fix it, you must delete old kernels.
First, you must list all of them and I recomend remove the oldest and keep the last two newest (if you have problems with the last, you can use the other).

To list all of them, use this command:

# dpkg -l linux-image-\* | grep ^ii | awk '{print $2}'

Now, you must purge the oldest kernels with the following command:

# sudo apt-get purge linux-image-4.13.0-{36,37,38}-generic

You need to change the values according to the values you have.
Finally, update grub

# sudo update-grub

Enjoy it!

How to convert kml to shape format throught ogr2ogr

You can create your kml file online with scribblemaps and download it to your computer.
If you create lines and markers in the same file, you will get this error:

ogr2ogr -f "ESRI Shapefile" file.shp file.kml -skipfailures
Warning 6: Normalized/laundered field name: 'description' to 'descriptio'
Warning 6: Field timestamp create as date field, though DateTime requested.
Warning 6: Field begin create as date field, though DateTime requested.
Warning 6: Field end create as date field, though DateTime requested.
Warning 6: Normalized/laundered field name: 'altitudeMode' to 'altitudeMo'
ERROR 1: Attempt to write non-point (LINESTRING) geometry to point shapefile.
ERROR 1: Attempt to write non-point (LINESTRING) geometry to point shapefile.
ERROR 1: Attempt to write non-point (LINESTRING) geometry to point shapefile.

To avoid it, you must create separated files for points, linestring or polygon as:

ogr2ogr point.shp point.kml -skipfailures -nlt point
ogr2ogr …

How to find the shortest path from an Internet Zoo topology file throught Postgis/pgrouting

First, you need to download a topology from Internet zoo.
I will use Napnet as example:


Now, we need to convert graphgml to sql (to load from postgres). To do it, you can use simplekml library for python or pykml.
It's important use geographic coordinates without altitude value and only write edges in the kml file.

After, you can follow this post to convert from kml to sql.

To begin, first we need to create a database and create a password (usually is postgres) for postgres user:

sudo -u postgres createdb testing
sudo -u postgres psql  

postgres=# \password postgres
Enter new password: 
Enter it again: 

postgres=# \q

Now, load the sql query:

psql -U postgres -d testing -q -f "Napnet.sql"
psql: FATAL:  Peer authentication failed for user "postgres"

To avoid this issue, you can run it throught this way:

psql 'host=localhost port=5432 dbname=testing user=postgres' -q -f "Napnet.sql"
psql:Napnet.sql:17: …