Client IP in SSH session

If you are writing a bash script and you want to know the remote public IP address of the client logged into the session via SSH, a simple way to do this is:

  • my_ip=`echo $SSH_CLIENT | awk '{ print $1}'`; echo $my_ip
Advertisements

Opening WebP with Gimp

If your version of Gimp does not yet have support for images in Google’s WebP format, you probably still can open them using gimp-webp plugin. Just check it out from Github and follow the instructions.


Connecting to MySQL without a password

There may be situations when you need to log into MySQL without providing a password. Well, not exactly without providing it at all, but without doing it in an interactive way or writing it in the command line in plain text. A real life example is doing database dump for backup purposes.

Luckily MySQL provides a mechanism to do just that. What you do is you create a file accessible only to you and MySQL and save your password within.

The procedure is very simple:

  • Go to your home directory
  • Create a hidden file named .my.cnf
  • Open it in a text editor
  • Create a section called “[client]” and provide your MySQL password, like this:
[client]
password=mypassword
  • Update access rights for better security:
chmod 600 .my.cnf

Failing “find” when parsing GPX XML with jQuery

When using jQuery for parsing GPX data (which is an XML format) you may experience a weird problem of being unable to access extra elements (nodes) added by software used to process the data, such as QGIS.

A typical example would be having such data in the file and being able to read “extensions” as an abject, being able to access its contents as text, but mysteriously failing when attempting to read “ogr:id”, which was added by QGIS:

<extensions>
<ogr:id>1</ogr:id>
</extensions>

The good news is that it is not your fault. Actually the culprit is jQuery itself, which fails to operate correctly with the node identifiers from different namespace due to a bug.

The easiest solution is to escape the colon with two backslashes, like this:

var mytest = $(this).find(‘extensions’).find(“ogr\\:id”).text();

Read more about it here.

 


OSRM: Profile profiles/car.lua not found

So you build OSRM map routing server and attempt to run it following the instructions on how to do it, only to see a message:

[error] Profile profiles/car.lua not found!

Well… You shouldn’t leave the “osrm-backend” directory. As the message says, OSRM was looking for a certain file in the “profiles” subdirectory of the location where you are now and it couldn’t find one. The chances are that after building and installing OSRM you went to another directory where your OSM map files are stored to test it.

The quickest solution is to simply create a symbolic link to the map file in the “osrm-backend” directory.

 


Pydio – file sharing and teamwork program

A rather convenient PHP-based system for sharing your files and collaborating with your colleagues and clients.

Formerly known as AjaXplorer, now called Pydio. Community version available for free here.

 

 


Which deb package owns the file?

To find out which package the file belongs to in a Debian based system (Ubuntu, Mint, BunsenLabs etc.), you may use apt-file.

Normally this utility is not installed by default, so it goes like this.

Install it:

  • sudo apt-get install apt-file

Make it update its database:

  • apt-file update

Use it on any file, for example:

  • apt-file find /usr/bin/blender