Geek as a platform

SFTP oneliner (as SCP)

Quick note to self:

Secure Copy (scp) (a one line command very easy to include in bash scripts) can be replaced by a similar Secure File Transfer (sftp) command, but the documentation is not very clear...

For instance, this command to transfer a file to a remote host using SCP:

scp src_file user@remote_host:/remote/path/dst_file

Can be replaced by this one, using SFTP:

sftp user@remote_host:/remote/path/ <<< $'put src_file dst_file'


# sftp root@ <<< $'put /tmp/test test_sftp'
Connected to
Changing to: /tmp/
sftp> put /tmp/test test_sftp
Uploading /tmp/test to /tmp/test_sftp
/tmp/test                                          100%    0     0.0KB/s   00:00

The idea is taken from a few StackOverflow threads, all the credit to them... I decided to put it together here, so I can find it easily.


2017 resolutions


Another entry in my personal online notebook (considering the number of visits of this site, I don't think it should be called blog or website)

We are only 11 day into the new year, so it is not too late for my 2017 resolutions. I'd rather post them here than keep them in a piece of paper on my desktop because, apparently, making goals "public" helps to succeed (or I can be publicly shamed at the end of the year)

Here they go:

1) The classics:

  • Work out more often: At least 3 times per week. No matter if it rains or snows.
  • Eat (more) healthy: It seems I'll be stuck in Spain for a few months (at least until April), so it will be a good opportunity to prepare some green juices (I bought a blender a couple of years ago, and I think I've turned it on 2 times).
  • Read (more) books: Goodreads helps me to track my reading habits... And they are far from impressive, around 12 books per year. It doesn't sound too bad, but considering I don't have family responsibilities, it is not enough. I think I should blame Netflix for this :)
  • Study something new: There are countless online courses nowadays available for free. I've already done a couple of them in edX and I'd like to do more. Coursera has some really interesting courses as well.
  • Improve my English pronunciation: My English is quite good, but still sounds like a spaniard speaking English.

2) Job related:

  • Look for a different role/position: I've been doing pretty much the same stuff for way too long. Time to change. Period.
  • Ramp up my python skills: I am kind of stuck with Python. It is enough for my current role (system engineering in a big telco, not development) but I'd say it is not good enough if I want to do something different (more IT related).
  • Learn some new languages: Go?
  • Ansible: I've been playing with Ansible every now and then for a couple of years, creating some playbooks for myself, but nothing fancy. I don't have the opportunity to use it in my current gig, so I'd need to look for a way to include it in my daily work.

3) Hobby related:

  • Fix my home network: 1 ISP router + 1 AP router + 1 openWRT (as firewall) + 1 NAS + several PC/laptops/smartphones/raspberry pi's = a hell of a mess.
  • Soldering: I have a bunch of ESP8266 chips laying around in a box. I should put them to good use.
  • Photo library housekeeping: I have traveled a lot these past years, and I have tons of photos in my NAS that I have not even seen. It needs a cleanup.
  • Post more (and better): I registered this domain back in 2005... And, even though no one reads this (the number of daily page reads is close to zero), I like to post stuff here. It's a good way to keep things available (thanks to github of course). I'd like to post more stuff, and if possible, more interesting.

I'd say this should be enough for 2017.


My 2016 in photos

(Pretty big pictures, sorry about that)

Saying hello to another year with some pictures... 2016 is been a good year, both personally and professionally:

  • I've been working in Japan for several months again... Best place for living as expat (IMO)


  • April: I never really liked south east Asia that much (too hot for my taste), but I have to say I had a really good time in Vietnam and Cambodia... Looking forward to going back there soon!


  • July: Raising sun at the top of Mt Fuji


  • August: Hawaii is the place to be. Period.


  • December: Vienna (European capital of Xmas) & Salzburg


I hope 2017 is as good as 2016, although I'd like to make some changes...

Happy New Year everyone


Related: 2015 in photos, 2014 in photos

My books in 2016

We just said goodbye to 2016, and as in 2015, here goes my Goodreads summary:


Unfortunately, I failed my reading challenge... I read 10 of the 13 books in the first half of the year, but I have been stuck with a Python book for months. And podcasts have not helped much :)

Happy reading!


Geolocating your holidays

Hi there

Tinkering with Python once again... Just for the sake of it :)

The idea is to generate a web page containing a Google Map with marks of your photo timestamps, geolocated in the map. I'm pretty sure Google Photos is able to do something similar (and better), but where's the fun in that?

For instance, I spent a few days in Kauai this summer, and this is the resulting map:

'Kauai photos timestamp'

Each mark is a photo I took, and you can see its timestamp moving the mouse over the marker...

Nothing fancy, but in case it is useful to you, this is the code:

#!/usr/bin/env python
Giving a directory as input:
1) the script will extract the dates and GPS coordinates of the NEF files
2) will add a marker in a Map 
3) print the HTML file

- EXIF data has to contain GPS tags
- exifread module installed
- Google Map API credentials
import exifread,sys,glob


html="""<!DOCTYPE html>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <title>Complex icons</title>
      html, body {
        height: 100%;
        margin: 0;
        padding: 0;
      #map {
        height: 100%;
    <div id="map"></div>

function initMap() {
  var map = new google.maps.Map(document.getElementById('map'), {
    zoom: 10,
    center: {lat: xxxLATxxx, lng: xxxLONGxxx}



function setMarkers(map) {
  for (var i = 0; i < captures.length; i++) {
    var capture = captures[i];
    var image = 'data:image/svg+xml,' + capture[3] + '%3C%2Ftext%3E%3C%2Fsvg%3E';
    var marker = new google.maps.Marker({
      position: { lat: capture[1], lng: capture[2] },
      map: map,
      icon: image,
      title: capture[0],
      zIndex: capture[3]
    <script async defer
</html> """ 

def formatme(mydata,reference):
    coordenates=(str(mydata).replace("[","").replace("]","").replace(" ","").split(","))


    ref = str(reference).strip()

    d = int(d.split("/")[0]) / int(d.split("/")[1]) if "/" in d else int(d)
    m = int(m.split("/")[0]) / int(m.split("/")[1]) if "/" in m else int(m)
    s = int(s.split("/")[0]) / int(s.split("/")[1]) if "/" in s else int(s)

    coor = d + (m / 60.0) + (s / 3600.0)
    return coor if ref == "N" or ref == "E" else -coor

def find_pics(pics_path):
    #Some more logic could be added here
    files = glob.glob(pics_path + "/*.NEF") 
    files.sort(key=lambda x: os.path.getmtime(x))
    return files

def get_GPS_data(id,path):
        #Get the EXIF tags
        with open(path, 'rb') as f:
            tags = exifread.process_file(f,details=False)
    except Exception as e:
        data = ["skip"]

    #Check we got the GPS tag data
    if "GPS GPSLongitude" not in tags and "GPS GPSLongitudeRef" not in tags:
        data = ["skip"]
        data = [path,"{0}".format(tags["EXIF DateTimeOriginal"]),formatme(tags["GPS GPSLatitude"], \
                tags["GPS GPSLatitudeRef"]),formatme(tags["GPS GPSLongitude"], tags["GPS GPSLongitudeRef"]),id]

    return data

if __name__ == "__main__":
        print("Usage: " + sys.argv[0] + " <path>")

    #List of pictures to process

    #List of pics, dates, lat, long, id
    captures = []
    for _, pic in enumerate(pics_list):
        item = get_GPS_data(_, pic) 
        if "skip" not in item: captures.append(item)

    # Create the JS code with the list of coordenates
    html_loop = "var captures = ["
    for capture in captures:
        html_loop = html_loop + "".join("['" + str(capture[1]) + "'," + str(capture[2]) + "," + str(capture[3]) + \
                    "," + str(capture[4]) + "],\n")
    html_loop = html_loop[:-2] + "]; "

    #Update center LAT/LONG  coordenates
    html = html.replace("xxxLATxxx",str(captures[0][2]))
    html = html.replace("xxxLONGxxx",str(captures[0][3]))
    #Update list of points
    html = html.replace("xxxCAPTURESxxx",html_loop)
    #Update API KEY
    html = html.replace("YOUR_API_KEY",G_API_KEY)


Stored in Github

The script is so simple that I am not even opening a file to write the output... Feel free to do it yourself, or redirect the output to a file:

# python > mymap.htm

Take care out there...