2019

IPv4 over IPv6 on Ubuntu

Solved the issue when connecting to archive.ubuntu.com takes too long. Edit /etc/gai.conf and uncomment line 4, which lets you keep IPv6 enabled, but sets the order of precedence to prefer IPv4 over IPv6. (askubuntu.com/a/354886) #tags: ubuntu, bittiger gai.config

#
#    For sites which prefer IPv4 connections change the last line to
#
precedence ::ffff:0:0/96 100

Setup a headless VM VirtualBox

# List virtual machines
VBoxManage list vms
"MyVM" {e4b0c92c-4301-4a7d-8af8-fe02fed00451}

# Start VM in headless mode
VBoxManage startvm MyVM --type headless

# Power off VM
VBoxManage controlvm MyVM poweroff

Accept Self-signed certif git

To permanently accept a specific certificate

Try http.sslCAPath or http.sslCAInfo. Adam Spiers’s answer gives some great examples. This is the most secure solution to the question. To disable TLS/SSL verification for a single git command

try passing -c to git with the proper config variable, or use Flow’s answer:

git -c http.sslVerify=false clone https://example.com/path/to/git

To disable SSL verification for a specific repository

If the repository is completely under your control, you can try:

git config http.sslVerify false

Disabling TLS(/SSL) certificate verification globally is a terribly insecure practice. Don’t do it. Do not issue the above command with a --global modifier.

Ubuntu Bionic & phpmyadmin error

Warning in ./libraries/sql.lib.php#601 count(): Parameter must be an array or an object that implements Countable

Note
la solution est là : stackoverflow.com/a/49483740/3175946

remplacer

 (count($analyzed_sql_results['select_expr'] === 1)

par

 (count($analyzed_sql_results['select_expr']) === 1

dans /usr/share/phpmyadmin/libraries/sql.lib.php (ligne 613)

Recuperer les infos d’une URL en Java

Note
On utilise : import java.net.URL;
import java.net.*;
import java.io.*;

public class ParseURL {
  public static void main(String[] args) throws Exception {

    URL aURL = new URL("http://example.com:80/docs/books/tutorial"
                       + "/index.html?name=networking#DOWNLOADING");

    System.out.println("protocol = " + aURL.getProtocol()); //http
    System.out.println("authority = " + aURL.getAuthority()); //example.com:80
    System.out.println("host = " + aURL.getHost()); //example.com
    System.out.println("port = " + aURL.getPort()); //80
    System.out.println("path = " + aURL.getPath()); //  /docs/books/tutorial/index.html
    System.out.println("query = " + aURL.getQuery()); //name=networking
    System.out.println("filename = " + aURL.getFile()); ///docs/books/tutorial/index.html?name=networking
    System.out.println("ref = " + aURL.getRef()); //DOWNLOADING
  }
}

Auth. multiple factors

Warning
Ne pas oublier que les heures du serveur et du smartphone doivent être synchronisés !!

2020

Show most heavy files in dir

sudo du -h | sort -k 1n

Fix new MySQL8 password error

alter user 'DATABASE_NAME'@'%' identified with mysql_native_password by 'MYPASSWORD';

With MYSQL 8 you have new utf8

In order to import dump from MySQL 8 to legacy MySQL

  1. utf8mb4_0900_ai_ci convert it to utf8_general_ci

  2. utf8mb4 convert it to utf8

Bug API Platform with @ORM JSON

Warning
Attention à ne pas utiliser le type @ORM json avec api platform !! Il faut utiliser le type texte.

Config PHP dans VsCode

// in settings.json
"php.validate.executablePath": "/usr/local/bin/php"

Support adoc dans Gitea

Add this to the end of app.ini

[markup.asciidoc]
ENABLED = true
FILE_EXTENSIONS = .adoc,.asciidoc
RENDER_COMMAND = "asciidoctor -e -a leveloffset=-1 --out-file=- -"
; Input is not a standard input but a file
IS_INPUT_FILE = false

Run this in the container

apk --no-cache add asciidoctor

Relancer le container Gitea

Remove .DS_Store from Git repo

Remove existing files from the repository:

find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch

Add the line

.DS_Store

to the file .gitignore, which can be found at the top level of your repository (or created if it isn’t there already). You can do this easily with this command in the top directory

echo .DS_Store >> .gitignore
git add .gitignore
git commit -m '.DS_Store banished!'