HG-map 2
GIS, dev & data

Menu

  • Accueil
  • Blog
  • Tutos
  • Astuces
  • Exercices
  • À propos de moi

Privé

  • Pandas

Tests Fabrik

  • Formulaire devis
  • Utilisateurs

Connexion

  • Mot de passe perdu ?
  • Identifiant perdu ?

SQL Automatic deduplication

Détails
Mis à jour : 17 Janvier 2021
Clics : 2689
  • Database
  • SQL

All living databases has its duplicates. Depending on their nature or number, it may be interesting to dedupe them quickly. For this goal SQL is our friend.

Below a simple example in order to describe the main concepts of the method. Then you will be able to do this in more complex situations. Because the final formula is a bit long, we will proceed iteratively, to understand the different steps.

Lire la suite : SQL Automatic deduplication

Automate the opening of your favorite apps

Détails
Mis à jour : 16 Janvier 2021
Clics : 1746
  • Python

python picture

Maybe each morning you have to open some softwares, websites or any apps before to start working.

For me: my professional email box (Outlook), my personnal email box (Gmail), my testing email boxes (Thunderbird, Yahoo ...), Teams, the official CRM of my company, the unofficial CRM of my company, the marketing tools of my company, my Google shortcuts ... Hum, tired in the morning!

Thanks to Python and his libraries os and webbrowser, we can save time and neurons. Just add the code below in a Python script:

[code]import os
import webbrowser

os.startfile("outlook")
os.startfile("thunderbird")

webbrowser.open('https://hg2.hg-map.fr/')

os.startfile(r"C:\Users\Georges\Desktop\Communications\Gmail.lnk")
os.startfile(r"C:\Users\Georges\Desktop\Communications\Microsoft Teams.lnk")
os.startfile(r"C:\Users\Georges\Desktop\Communications\Yahoo.lnk")[/code]

Clicking into will open your favourite applications. Me I prefere store my scripts in a dedicated folder, and then add shortcuts on my desktop.

Maybe you should adapt the code according your OS and your apps subtilities. Here above for example, Outlook and Thunderbird are recognized by Python, and just need to mention their system names to the os library. A website need the webbrowser library, and the Google shortcuts need the os library but from their full paths.

 

The Webmaster's doggy joke

Détails
Mis à jour : 9 Septembre 2020
Clics : 1390

Thanks to dog.ceo and its API, you can display a random beautiful dog in a website. Just add the code below in your PHP:

[code]<img style="width: 100%;" src="/<?php
$my_json = "https://dog.ceo/api/breeds/image/random" ;
$my_content = file_get_contents($my_json);
$my_content_dec = json_decode($my_content);
$url_img = $my_content_dec->message ;
print $url_img;
?>" alt="Oh my dog!" title="Oh my dog!">[/code]

 To restrict the joke to your users (more polite), just enclose the code with this kind of PHP condition.

[code]<?php if ($user->id != 0): ?>
...
<?php endif; ?>[/code]

 In Joomla a perfect spot to put it: templates/your_template/index.php, into the <div id="aside" class="span3">.

Please let me know if you find other APIs like it!

Fix unwanted line breaks with Notepad and some regex

Détails
Mis à jour : 19 Juillet 2020
Clics : 3117
  • Database
  • SQL
  • Data mining
  • Web scraping
  • Notepad
  • Regex

When you have to import files as text, csv, etc ... into an SQL database, non-desired line breaks (often from notes fields, text boxes,  <BR> tags, tabs, or other misinterpreted HTML ...) are very painful. It may fail your import, or be a waste of time. Exploring one's file with Notepad is sometimes necessary.

Complete 4-step correction

How to effectively manage these line breaks?

In this standard example, we want to identify and fix lines that do not start with a double quote (caused by line breaks) within a file where healthy lines start with a double quote.

Lire la suite : Fix unwanted line breaks with Notepad and some regex

Django REST API

Détails
Mis à jour : 13 Avril 2020
Clics : 16134
  • Database
  • Django
  • API

Django REST API 2Here some tips about Django REST Framework (DRF) with Django 3.

Official website

Quick install

[code]> pip install djangorestframework[/code]

Then in settings.py:

[code]INSTALLED_APPS = [
...
'rest_framework',
][/code]

Let's go!

Lire la suite : Django REST API

Page 3 sur 4

  • 1
  • 2
  • 3
  • 4