## The algorithm for mining bitcoin in Python

This article describes a python implementation of bitcoin mining that relies on an algorithm based on a double hash SHA-256.

## Introduction – Principle of the bitcoin mining agorithm

Miners on the bitcoin network should look for the nonce which is a 32-bit number. The miner will successively test several NONCEs (1,2,3 …. 10 ^ 32-1), for each of the nonce he creates the following header and hasher twice with a SHA-256 bit hash function.

Once the hash obtained, the miner must then check that the hash obtained is lower than the target difficulty factor of the block. If the hash obtained is greater then the nonce is not the correct one, another must be tested.

## Example on block 671712

If you are using a blockhain bitoin explorer (for example blocstream info), if we take for example block 671712:

https://blockstream.info/block/000000000000000000062a949bc297739a12e639ba9e2107638b469afe11d0f8?expand

In this case here is an algorithm in python which allows to mine this block:

In this simulation I display the header and the calculated hash as well as the hash rate.

The nonce to find for block 671712 was 4107802144

This algorithm starts with a nonce = 4107802144 – 400 we will act as if we were very close to finding the block (400 double hashes are missing to find the block):

```import hashlib
from hashlib import sha256
import time
import struct
import binascii
import datetime
from binascii import unhexlify, hexlify
from dateutil import parser
from datetime import datetime
from datetime import timedelta

nontrouve = True
dtprec = datetime.now()
inonc = 4107802134 - 400 #Starting 400 before the good nonce
resultat = []

while(nontrouve):
inonc +=1
if(inonc%50==0):
print(str(round(timedelta(seconds=1)/(datetime.now() - dtprec))) + ' H/s')
dtprec = datetime.now()
binascii.hexlify(binascii.unhexlify('000000000000000000078908d256fa7a9f97b2e1ea532fb1ce45ee4bf050d221')[::-1]).decode()+
binascii.hexlify(binascii.unhexlify('c504fc3a406f11c7c5b598da7f50916f4e298041e6f9b91535a80db113af109a')[::-1]).decode() +
binascii.hexlify(struct.Struct('<L').pack(int(hex(int(parser.parse('2021-02-22 15:14:22 GMT +1').timestamp())-3600),16))).decode() +
binascii.hexlify(struct.Struct('<L').pack(int("0x170cf4e3",16))).decode() +
binascii.hexlify(struct.Struct('<L').pack(int(hex(inonc),16))).decode())
dt1 = datetime.now().strftime("%H:%M:%S.%f")
hexlify(hash).decode("utf-8")
hexlify(hash[::-1]).decode("utf-8")
hash=hexlify(hash[::-1]).decode("utf-8")
resultat.append([round(int(hash,16)/10**65)])

MAX_TARGET = int("00000000FFFF0000000000000000000000000000000000000000000000000000", 16)
Difficulty = 21724134900047.27
target = int(MAX_TARGET / Difficulty)
target32 = '{:0>64x}'.format(target)
if(int(hash,16) < int(target32,16)):
print('###########BLOC MINED###################')
print('HASH=' + hash)
print('NONCE=' + str(inonc))
print('NONCE (hex)=' + hex(inonc))
print('###########BLOC MINED###################')
break```

The output is :

```1149 H/s
4405 H/s
4115 H/s
1534 H/s
3831 H/s
2392 H/s
4386 H/s
3165 H/s
###########BLOC MINED###################
HASH=000000000000000000062a949bc297739a12e639ba9e2107638b469afe11d0f8
NONCE=4107802144
NONCE (hex)=0xf4d81620
###########BLOC MINED###################```

## External link- bitcoin mining with python

https://en.bitcoin.it/wiki/Block_hashing_algorithm

## Android SDK Exception in thread “main” java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema

When you try to lauchn the utility sdkmanager for android SDK you get the following error : Exception in thread “main” java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema

## How to solve this error ?

Solution is to install JDK 8 :

```brew cask uninstall java
touch ~/.android/repositories.cfg

In some case the right command is :

`brew install openjdk@8`

## Install Android Command line tools

Little guide to setup android sdk from homebrew and install Android Command line tools

## macOS(via Homebrew)

` brew install --cask android-sdk`

## Test the installation of android SDK

` sdkmanager --help `

## Godot status != 0x8CD5 in RasterizerGLES2 – rasterizer_gles2.cpp

To solve this error Godot status != 0x8CD5 in RasterizerGLES2 – rasterizer_gles2.cpp a way to do it is to force using OPENGL2.1 with parameter `--video-driver GLES2` the complete command is :

`godot.exe --path pathproject --video-driver GLES2 -e`

If you get this error modules/speech_to_text/register_types.cpp:2:10: fatal error: ‘object_type_db.h’ file not found you need to do this :

Go into directory source of GODOT and modules/speech_to_text :

File to open is register_types.cpp

You will see use of a header file

`#include "object_type_db.h"`

It changes between GODOT 2 and 3 from object_type_db.h to class_db.h

So chang it by :

`#include "core/object/class_db.h"`

Save and execute GODOT source compilation again it will works.

I get similar error on

You need to open modules/speech_to_text/stt_config.h and modify :

`#include "core/resource.h"`

By :

`#include "core/io/resource.h"`

so i do the following in stt_error.h :

```#include "core/object.h"
#include "core/ustring.h"```
```#include "core/object/object.h"
#include "core/string/ustring.h"```

https://docs.godotengine.org/en/3.0/development/compiling/compiling_for_osx.html

## TypeError: can_build() takes 1 positional argument but 2 were given – Godot Compilation

If you get this type of errors TypeError: can_build() takes 1 positional argument but 2 were given when trying to compile Godot you have to do this :

When i tried to compile with scons i got this errors :

```scons: Reading SConscript files ...
Automatically detected platform: osx
Building for macOS 10.12+, platform x86-64.
TypeError: can_build() takes 1 positional argument but 2 were given:
File "/Users/myuser/godot/SConstruct", line 556:
if config.can_build(env, selected_platform):```

## How to solve this error ?

First check you version of scons by launching :

`scons -v`

It will give you the scons path :

`SCons path: ['/usr/local/Cellar/scons/4.1.0.post1/libexec/lib/python3.9/site-packages/SCons']`

You then notice the use of python 3.9

You have to update your python to 3.9 :

Update Python easy update to Python 3.9 with homebrew – To update Mac os python from an older version to the latest python example python 3.9.1 you can do the folowing :

This article briefly describes how to replace its version of python on Mac. I wrote a similar article some time ago.

I used Homebrew to get the latest python as describe on https://formulae.brew.sh/formula/python@3.9:

`brew install python@3.9`
```python --version
Python 3.8.5
python3 --version
Python 3.8.5```

You see that it stays on the older version.

## Detect where python or python3 is setup

I had to first verify where my python command is pointing, by launching :

`which python`

It gave me in my case:

`/Users/myuser/.pyenv/shims/python`

You need also to verify where is python3 command if you have different versions :

`which python3  `

I get :

`/Users/myuser/.pyenv/shims/python3`

## Replace the version

I need to replace the version of the both command python and python3 by launching :

`ln -s -f /usr/local/bin/python3.9 /Users/myuser/.pyenv/shims/python3`

And also launch :

`ln -s -f /usr/local/bin/python3.9 /Users/myuser/.pyenv/shims/python`

The you can test it works :

```python --version
Python 3.9.1
python3 --version
Python 3.9.1```

## Come back on GODOT compilation with Scons :

You need to localize the module that is bad in GODOT modules directory

For example i localize speech_to_text that was bad in config.py

So i directly modify config.py from this directory from can_build(env) to can_build(env, platform):

```import os  # system()

def can_build(env, platform):
if platform == "x11":
has_pulse = os.system("pkg-config --exists libpulse-simple") == 0
has_alsa = os.system("pkg-config --exists alsa") == 0
return has_pulse or has_alsa
elif platform in ["windows", "osx", "iphone", "android"]:
return True
else:
return False

def configure(env):
pass
```

And it works :

```godot % scons
Automatically detected platform: osx
Building for macOS 10.12+, platform x86-64.
YASM is necessary for WebM SIMD optimizations.
WebM SIMD optimizations are disabled. Check if your CPU architecture, CPU bits or platform are supported!
Checking for C header file mntent.h... no
scons: Building targets ...
[Initial build] Compiling ==> platform/osx/crash_handler_osx.mm
[Initial build] Compiling ==> platform/osx/os_osx.mm
```

## TypeError: can_build() takes 1 positional argument but 2 were given – Internal links :

This article briefly describes how to replace its version of python on Mac. I wrote a similar article some time ago.

## Mac os update Python easy update to Python 3.9 with homebrew

Update Python easy update to Python 3.9 with homebrew – To update Mac os python from an older version to the latest python example python 3.9.1 you can do the folowing :

This article briefly describes how to replace its version of python on Mac. I wrote a similar article some time ago.

## Introduction – update to Python 3.9.1 – HOMEBREW

I used Homebrew to get the latest python as describe on https://formulae.brew.sh/formula/python@3.9:

`brew install python@3.9`
```python --version
Python 3.8.5
python3 --version
Python 3.8.5```

You see that it stays on the older version.

## Detect where python or python3 is setup

I had to first verify where my python command is pointing, by launching :

`which python`

It gave me in my case:

`/Users/myuser/.pyenv/shims/python`

You need also to verify where is python3 command if you have different versions :

`which python3  `

I get :

`/Users/myuser/.pyenv/shims/python3`

## Replace the version

I need to replace the version of the both command python and python3 by launching :

`ln -s -f /usr/local/bin/python3.9 /Users/myuser/.pyenv/shims/python3`

And also launch :

`ln -s -f /usr/local/bin/python3.9 /Users/myuser/.pyenv/shims/python`

The you can test it works :

```python --version
Python 3.9.1
python3 --version
Python 3.9.1```

## Mac os update Python – Internal links :

This article briefly describes how to replace its version of python on Mac. I wrote a similar article some time ago.

## Comment faire un ping sur Filius ?

Comment faire un ping sur Filius ? Filius est un logiciel de simulation de réseau. Ce premier article présente la création d’un réseau ad hoc entre deux ordinateurs et l’utilisation la commande ping.

## Etape 1 :

Ajouter les 2 ordinateurs et les relier par un câble réseau.

## Etape 2 :

Configurer le nom et l’adresse IP des ordinateurs, soit “Ordinateur A” : 198.168.0.10 et “Ordinateur B” : 198.168.0.20

## Etape 3 :

Démarrer et installer la ligne de commande sur l’ordinateur A en cliquant dessus.

## Etape 4 :

Utiliser la commande ping 192.168.0.20. Ping est une commande qui envoie des paquets réseau vers l’adresse demandée et qui mesure les temps de réponse.

## Filius ping – Liens Externes

https://www.ionos.fr/digitalguide/serveur/outils/commande-ping/

https://fr.wikipedia.org/wiki/Ping_(logiciel)

https://www.cisco.com/c/fr_ca/support/docs/ip/routing-information-protocol-rip/13730-ext-ping-trace.html

## Filius ping -Liens Internes

https://128mots.com/index.php/en/category/non-classe-en/

https://128mots.com/index.php/category/non-classe/

## starthost failed, but will try again: config: please provide an ip address

starthost failed, but will try again: config: please provide an ip address

❌ Exiting due to GUEST_PROVISION: Failed to start host: config: please provide an IP address : Error with kubernetes and minikube `minikube`

## Introduction – Exiting due to GUEST_PROVISION

So, if you are trying to start the kubernetes tutorial from https://kubernetes.io/fr/docs/setup/learning-environment/minikube and you want to start minikube by the command :

`minikube start`

Then, you are getting this error :

```minikube v1.17.1 sur Darwin 10.15.7
✨  Utilisation du pilote ssh basé sur le profil existant
👍  Démarrage du noeud de plan de contrôle minikube dans le cluster minikube
🤦  StartHost failed, but will try again: config: please provide an IP address
😿  Failed to start ssh bare metal machine. Running "minikube delete" may fix it: config: please provide an IP address

❌  Exiting due to GUEST_PROVISION: Failed to start host: config: please provide an IP address

😿  If the above advice does not help, please let us know:
👉  https://github.com/kubernetes/minikube/issues/new/choose

```

## Solution – starthost failed, but will try again: config: please provide an ip address

And, the best way to solve this problem is to run the following command. Also you can find information on https://minikube.sigs.k8s.io/docs/drivers/ssh/

If you are running with docker you will find on https://minikube.sigs.k8s.io/docs/drivers/docker/ what i have done is to delete the last minkube cluster and rerun with the command specify the docker :

`minikube delete`

You will get :

```🔄  Désinstallation de Kubernetes v1.20.2 à l'aide de kubeadm…
🔥  Trying to delete invalid profile minikube```

And then :

`minikube start --driver=docker`

This is working :

```😄  minikube v1.17.1 sur Darwin 10.15.7
✨  Utilisation du pilote docker basé sur la configuration de l'utilisateur
👍  Démarrage du noeud de plan de contrôle minikube dans le cluster minikube
🚜  Pulling base image ...```