Joplin & Python ( gmplot Google Map) : How to create a Maps with REST API and data in Joplin ?

30 x served & 10 x viewed

Step 0 : Install Joplin and activate the REST API ( https://joplin.cozic.net/api/ ) .

Step 1: Install gmplot with pip

$ pip install gmplot
Collecting gmplot
  Downloading https://files.pythonhosted.org/packages/e2/b1/e1429c31a40b3ef5840c16f78b506d03be9f27e517d3870a6fd0b356bd46/gmplot-1.2.0.tar.gz (115kB)
    100% |████████████████████████████████| 122kB 1.0MB/s 
Requirement already satisfied: requests in /usr/local/lib/python3.7/site-packages (from gmplot) (2.21.0)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in /usr/local/lib/python3.7/site-packages (from requests->gmplot) (1.24.1)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/site-packages (from requests->gmplot) (2018.11.29)
Requirement already satisfied: idna<2.9,>=2.5 in /usr/local/lib/python3.7/site-packages (from requests->gmplot) (2.8)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.7/site-packages (from requests->gmplot) (3.0.4)
Building wheels for collected packages: gmplot
  Building wheel for gmplot (setup.py) ... done
  Stored in directory: /Users/...../Library/Caches/pip/wheels/81/6a/76/4dd6a7cc310ba765894159ee84871e8cd55221d82ef14b81a1
Successfully built gmplot
Installing collected packages: gmplot
Successfully installed gmplot-1.2.0

The source code : (change your token)

#
# Version 1 
# for Python 3
# 
#   ARIAS Frederic
#   Sorry ... It's difficult for me the python :)
#

from time import gmtime, strftime
import time
import json
import requests
import os
import gmplot

strftime("%Y-%m-%d %H:%M:%S", gmtime())
start = time.time()

#Token
ip = "127.0.0.1"
port = "41184"
token = "Put your token here"

nb_request = 0
nb_plot = 0
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
url_notes = (
    "http://"+ip+":"+port+"/notes?"
    "token="+token
)
x=[] #longitudes
y=[] #latitudes
try:
    resp = requests.get(url_notes, headers=headers)
    nb_request += 1
    resp.raise_for_status()
    resp_dict = resp.json()
    #print(resp_dict)
    for my_note in resp_dict:
        #print(my_note.get('id'))
        url_notes2 = (
    "http://"+ip+":"+port+"/notes/"+my_note.get('id')+"?fields=longitude,latitude&"
    "token="+token
)
        try:
           resp2 = requests.get(url_notes2, headers=headers)
           nb_request += 1
           resp2.raise_for_status()
           resp_dict2 = resp2.json()
           #print(resp_dict2)
           long = resp_dict2.get('longitude')
           lat = resp_dict2.get('latitude')
           if (long != '0.00000000'):
              #print(long,lat)
              nb_plot += 1
              if (nb_plot == 1):
                 gmap1 = gmplot.GoogleMapPlotter(float(lat), float(long), 13 )
              x.append(float(long))
              y.append(float(lat))
        except requests.exceptions.HTTPError as e:
             print("Bad HTTP status code:", e)
        except requests.exceptions.RequestException as e:
             print("Network error:", e)
except requests.exceptions.HTTPError as e:
    print("Bad HTTP status code:", e)
except requests.exceptions.RequestException as e:
    print("Network error:", e)

gmap1.scatter( y, x, '#FF0000', size = 10, marker = False )
gmap1.draw("mymap.html")

print ("Number total of request",nb_request)
print ("Number total of pin",nb_plot)

After clic on mymap.html on same folder.

Note n°1 : JOPLIN is robust

 $ time python3 JoplinToGoogleMap.py 
Number total of request 1927
Number total of pin 643


real 0m8.401s
user 0m4.564s
sys 0m0.577s

In 9 seconds, 1927 requests !! JOPLIN it’s perfect.

Note n°2 : To increase the size of the PIN it’s here ( size = 10 ) :

gmap1.scatter( y, x, '#FF0000', size = 10, marker = False )

NAIAD : Atelier participatif du eudi 20 Décembre 2018, IMREDD Nice

28 x served & 2 x viewed

Le site : http://naiad2020.eu .

Objectifs de la réunion : 

  • Valider les méthodes d’évaluation des critères de choix des mesures de réduction du risque d’inondation qui vont alimenter l’Analyse Coût-Bénéfice (ACB) et l’Analyse Multicritères (AMC), 
  • Connaître les avis des partenaires sur la nature et la pertinence des méthodes ; 
  • Recueillir les suggestions des partenaires sur les améliorations nécessaires ; 
  • Recueillir des idées sur les questions à poser pour l’enquête socio-culturelle.

Principales conclusions

  • L’ensemble des participants semble convenir que les critères présentés couvrent l’ensemble de la problématique liée aux inondations et à l’aménagement du territoire.
  • Il y a consensus sur la pertinence des méthodes et des indicateurs proposés pour évaluer les critères.
  • Il a été souligné que les évaluations doivent être faites à l’échelle du bassin versant et prendre en compte le changement climatique et les évolutions de l’urbanisme.
  • Il a été souligné qu’il est important de considérer les risques en cascade mais qu’il faut considérer en priorité le ruissellement. 
  • Il a été souligné la nécessité des indicateurs non monétaires ou qualitatifs en complément des indicateurs monétaires.
  • Il y a eu consensus sur la nécessité d’une enquête socioculturelle auprès de la population. Cependant, cette enquête doit être menée avec précautions afin de ne pas interférer avec les démarches déjà lancées par les acteurs locaux : DUP lancée par le CASA et l’enquête publique sur la révision du PPRI lancée par la DDTM.
  • Il a été souligné la nécessité de proposer et d’évaluer différents scénarii de gestion du risque d’inondation.

Merci à NAIAID pour le compte-rendu !

How to import data of WordPress (Feed RSS) to Joplin ?

33 x served & 11 x viewed

Install JOPLIN : https://joplin.cozic.net ,  and start REST API. (Easy)

Step 1 : Put this script in folder.

Step 2 : Edit the script and put your token 

Step 3 : Run the script

The script :

#
# Version 1 
# for Python 3
# 
#   ARIAS Frederic
#   Sorry ... It's difficult for me the python :)
#

import feedparser
from os import listdir
from pathlib import Path
import glob
import csv
import locale
import os
import time
from datetime import datetime
import json
import requests

#Token
ip = "127.0.0.1"
port = "41184"
token = "Put your token here"

nb_import = 0;
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}

url_notes = (
    "http://"+ip+":"+port+"/notes?"
    "token="+token
)
url_folders = (
    "http://"+ip+":"+port+"/folders?"
    "token="+token
)
url_tags = (
    "http://"+ip+":"+port+"/tags?"
    "token="+token
)
url_ressources = (
    "http://"+ip+":"+port+"/ressources?"
    "token="+token
)

#Init
Wordpress_UID = "12345678901234567801234567890123"
UID = {}

payload = {
    "id":Wordpress_UID,
    "title":"Wordpress Import"
}

try:
    resp = requests.post(url_folders, data=json.dumps(payload, separators=(',',':')), headers=headers)
    resp.raise_for_status()
    resp_dict = resp.json()
    print(resp_dict)
    print("My ID")
    print(resp_dict['id'])
    WordPress_UID_real = resp_dict['id']
    save = str(resp_dict['id'])
    UID[Wordpress_UID]= save
except requests.exceptions.HTTPError as e:
    print("Bad HTTP status code:", e)
except requests.exceptions.RequestException as e:
    print("Network error:", e)

feed = feedparser.parse("http://www.cyber-neurones.org/feed/")

feed_title = feed['feed']['title']
feed_entries = feed.entries

numero = -2
nb_entries = 1
nb_metadata_import = 1

while nb_entries > 0 : 
  print ("----- Page ",numero,"-------")
  numero += 2
  url = "http://www.cyber-neurones.org/feed/?paged="+str(numero)
  feed = feedparser.parse(url)
  feed_title = feed['feed']['title']
  feed_entries = feed.entries
  nb_entries = len(feed['entries'])
  for entry in feed.entries:
     nb_metadata_import += 1
     my_title = entry.title
     my_link = entry.link
     article_published_at = entry.published # Unicode string
     article_published_at_parsed = entry.published_parsed # Time object
     article_author = entry.author
     timestamp = time.mktime(entry.published_parsed)*1000
     print("Published at "+article_published_at)
     my_body = entry.description
     payload_note = {
         "parent_id":Wordpress_UID_real,
         "title":my_title,
         "source":"Wordpress",
         "source_url":my_link,
         "order":nb_metadata_import,
         "user_created_time":timestamp,
         "user_updated_time":timestamp,
         "author":article_author,
         "body_html":my_body
         }
     payload_note_put = {
         "source":"Wordpress",
         "order":nb_metadata_import,
         "source_url":my_link,
         "user_created_time":timestamp,
         "user_updated_time":timestamp,
         "author":article_author
         }

     try:
         resp = requests.post(url_notes, json=payload_note)
         resp.raise_for_status()
         resp_dict = resp.json()
         print(resp_dict)
         print(resp_dict['id'])
         myuid= resp_dict['id']
     except requests.exceptions.HTTPError as e:
         print("Bad HTTP status code:", e)
     except requests.exceptions.RequestException as e:
         print("Network error:", e)

     url_notes_put = (
    "http://"+ip+":"+port+"/notes/"+myuid+"?"
    "token="+token
)
     try:
         resp = requests.put(url_notes_put, json=payload_note_put)
         resp.raise_for_status()
         resp_dict = resp.json()
         print(resp_dict)
     except requests.exceptions.HTTPError as e:
         print("Bad HTTP status code:", e)
     except requests.exceptions.RequestException as e:
         print("Network error:", e)

Encore une demande de rançon : 15LZuFSVyDAoaNLtbh4ru7ZQWvZxEosCaf

38 x served & 20 x viewed

Dans la source de l’email : la personne n’est pas à son premier essai : https://www.bitcoinabuse.com/reports/17X5raT9zqDPBi4L8NrvwSQ77LuG9QjFCH .

X-SPAMOUT-IP: 203.239.130.5 (TRUST)
X-Original-SENDERIP: 203.239.130.5
X-SPAMOUT-COUNTRY: KR
X-SPAMOUT-FROM: <jt.joo@elim.net>
X-SPAMOUT-RELAY: IP

Il est déjà dans les abuses : https://www.bitcoinabuse.com/reports/15LZuFSVyDAoaNLtbh4ru7ZQWvZxEosCaf

Voici l’email :

Hi, this account is hacked! Renew the password immediately!
You might not know anything about me and you are probably surprised for what reason you are getting this particular message, proper?
I am ahacker who burstyour emailand all devicessome time ago.
Do not attempt to msg me or look for me, it is hopeless, because I sent you this message from YOUR account that I've hacked.
I have build in malware soft on the adult vids (porno) site and suppose that you have enjoyed this site to have fun (you understand what I want to say).
During you were watching video clips, your browser started out functioning as a RDP (Remote Control) with a keylogger that granted me permission to access your desktop and camera.
Then, my applicationgotall data.
You have put passcodes on the web-sites you visited, I intercepted them.
Of course, you can modify each of them, or have already changed them.
Even so it does not matter, my malware updates needed data every time.
What did I do?
I made a backup of your device. Of all files and each contact.
I created a dual-screen videofile. The 1st screen reveals the clip you had been watching (you've got an interesting preferences, ha-ha...), and the 2nd part shows the movie from your web camera.
What exactly must you do?
Great, I think, 1000 USD will be a inexpensive amount of money for this very little riddle. You'll make your deposit by bitcoins (in case you don't recognize this, search “how to buy bitcoin” in Google).
My bitcoin wallet address:
15LZuFSVyDAoaNLtbh4ru7ZQWvZxEosCaf
(It is cAsE sensitive, so just copy and paste it).
Warning:
You have only 2 days to make the payment. (I built in an unique pixel in this e-mail, and at the moment I understand that you have read through this email).
To monitorthe reading of a messageand the actionsin it, I usea Facebook pixel. Thanks to them. (Everything thatis appliedfor the authorities can helpus.)

If I do not get bitcoins, I shall undoubtedly offer your video to all your contacts, including family members, colleagues, etc?

Installation de pip sur Mac OS

25 x served & 1 x viewed

Voici ce que j’ai fait pour faire l’installation de pip sur Mac OS :

$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1662k  100 1662k    0     0   560k      0  0:00:02  0:00:02 --:--:--  560k

$ python3 get-pip.py
Collecting pip
  Downloading https://files.pythonhosted.org/packages/d7/41/34dd96bd33958e52cb4da2f1bf0818e396514fd4f4725a79199564cd0c20/pip-19.0.2-py2.py3-none-any.whl (1.4MB)
    100% |████████████████████████████████| 1.4MB 154kB/s 
Installing collected packages: pip
  Found existing installation: pip 18.1
    Uninstalling pip-18.1:
      Successfully uninstalled pip-18.1
Successfully installed pip-19.0.2

$ pip install feedparser
Collecting feedparser
  Downloading https://files.pythonhosted.org/packages/91/d8/7d37fec71ff7c9dbcdd80d2b48bcdd86d6af502156fc93846fb0102cb2c4/feedparser-5.2.1.tar.bz2 (192kB)
    100% |████████████████████████████████| 194kB 500kB/s 
Building wheels for collected packages: feedparser
  Building wheel for feedparser (setup.py) ... done
  Stored in directory: ....
Successfully built feedparser
Installing collected packages: feedparser
Successfully installed feedparser-5.2.1