Nicolas BAPTISTA - Blog of a Parisian software architect

This blog contains 47 articles

N I C O L A S    B A P T I S T A

PERSONNAL BLOG

SOFTWARE ARCHITECT • JAVASCRIPT DEVELOPER • DESIGNER


LinkedIn Contact Github More...


Rename git branch

Use git command line (with git bash on Windows) to change the branch name.

1 – Be sure you are on the right branch

Firstly, you should be on your current branch (the branch you want to rename) with git checkout.

2 – Change the name of the branch locally

Secondly, you should rename the branch with the following command:

git branch -m <the_new_branch_name>

The new branch name should be valid, with no space. If you use special characters you should use quotes like:

git branch -m “let’s-put-a-complicated-name”

3 – Change the name of the branch remotely

You can now change the name of the branch remotely so it’s also changed on github / gitlab / bitbucket etc.
To do push it use:

git push origin HEAD:<old_branch_name>

If it’s a complicated name you can still use the quotes:
git push origin HEAD:”it’s-an-old-branch-name”

Résoudre “Désolé… Nous rencontrons des problèmes de serveur temporaires.” sur Word et Office 365

Si vous utilisez Word sur Windows 7 il est possible que vous n’arrivez tout simplement pas à vous connecter sur votre compte Office 365 et donc que vous ne pouvez pas utiliser des outils comme Word et Excel qui nécessite une license.

La connexion au compte génère l’erreur “Désolé… Nous rencontrons des problèmes de serveur temporaires.” ou une page blanche

Installer Internet Explorer 11 / Install Internet Explorer 11

Vous devez mettre à jour Internet Explorer, même si cela parait bête, c’est bel et bien ce qu’il faut faire:

Lien: https://www.microsoft.com/fr-fr/download/details.aspx?id=41628

Redémarrer l’ordinateur / Restart the computer

Une fois Internet Explorer mis à jour vous devez redémarrer Windows

Mettre à jour Word ou Office 365 / Update Word or Office 365

Une fois redémarré, si vous ne pouvez pas vous connecter, il faut mettre à jour Word / Office 365 :

The good way to create the SAAS application project

The bad way

FIND AN IDEA, A BUSINESS MODEL
BUILD THE PRODUCT FROM THAT IDEA
TRY TO SELL THE PRODUCT
It will be hard to find people interested to the product

The good way

FIND AN AUDIENCE
ANALYSE THEIR PROBLEMS
FIND A SOLUTION TO THEIR PROBLEMS WITH A PRODUCT
SELL THE PRODUCT TO THE AUDIENCE
It is more easy because you already know interested people

After doing it in the good way, what will matter is the execution of making this product real.

The most you push your idea of business forward with effort making it real, the most it will works.

An idea without any action is nothing worth.

AWS Certificate Manager – The SCAM service of AWS

If you are using the services of AWS you should be careful about some services. It is possible that you may want a certificate for your application. You may use free certificate like let’s encrypt but AWS is offering a “Certificate Manager” and you can find it like any other services:

400$/month per private certificate

But, on the pricing page, you can find that this service cost 400$/month, no matter if you use it or not, it will take you the price of renting a car.

No way to delete or stop this recurring amount of money from the account

On the documentation, you can find that the service will stop “until you delete the CA”. I can tell you that this information is not really true as this service still take money without the CA. So additionally this service have a very not predictable way of taking money, and you don’t really know when it will stop, even if you check there is no certificate and you read carefully the documentation.

Conclusion

Git : Don’t commit node_modules except a file in a library

If you are using the node_modules in your Node.JS / Javascript / Typescript project you should exclude to commit all the libraries used by your application with this line in the .gitignore file:

.gitignore

node_modules/

But, you may need to modify a file in the /node_modules folder, excluded in the .gitignore

Force commit a file in a excluded folder in .gitignore

If you want to fix a file in a library that makes some problems in your application, you may want to modify the library directly in /node_modules (the case you are using the last version of the library, you can check on https://www.npmjs.com/ if you are using the last version in your package.json)

In my case, I modified node_modules/react-native-firebase/ios/RNFirebase/notifications/RNFirebaseNotifications.m a library that is not changed since 2 years and have a problem in my application. You can of course make a git issue on the official page but if you need it to work fast, you may want to commit it directly in your project and it is fixed.

After you made the change in the library, you can commit with git add -f …

In my case:

git add -f node_modules/react-native-firebase/ios/RNFirebase/notifications/RNFirebaseNotifications.m
You can see your file to be commit in your Git Desktop, and my node_modules folder is excluded in .gitignore

How to remove git token on git project after a failed git pull

After doing a git pull is it possible you have an error because your Git Token is not valid anymore, here is an exemple:

# git pull
remote: HTTP Basic: Access denied
fatal: Authentication failed for 'https://gitlab-ci-token:YOURTOKEN@gitlab.com/YOURPROJECT.git/'

In order to do the git pull we want to use our credential with the LOGIN / PASSWORD that we use to access GitLab.

Solution 1 : Git pull one time with login (temporary)

# git pull https://gitlab.com/YOURPROJECT.git

Solution 2 : Change the origin URL to HTTPS (permanent)

# git remote set-url origin https://gitlab.com/YOURPROJECT.git
# git pull

It will ask your login and password for the git pull and will not use the git token anymore.

Kill Node.JS service by port / Arrêter un service Node.JS avec son port

🇬🇧Dear all, is it possible you want to kill a Node.JS service with your linux machine, that is running on a specific port

Il est possible que vous voulez arrêter un processus Node.JS sur un port précis sur votre machine linux🇫🇷

Here is the magic command to find and kill the Node.JS process

Voici la commande magique qui permet de trouver et arrêter de processus avec son port

netstat -pluton
It looks like the name of the famous planet / Moyen mémo-technique on pense à cette p’tite planete

Then you should be able to find the process (PID) with the port associated

Vous devriez avec cette commande trouver le nom du processus (PID) avec le port associé

PORT 4000:

React native with Android – Fix : Device unauthorized

Check developer is enabled in the phone settings

One reason your phone is not detected is that you don’t have enabled the developer mode in the Android Settings.

Check the connected android devices with adb devices

Now you can check if your phone is connected with adb devices

sh-3.2# adb devices
* daemon not running; starting now at tcp:5037
* daemon started successfully
List of devices attached
CBAA004484J41536762     unauthorized

Authorise your device with adb kill-server and adb devices

If your phone still not asking anything while connected, you can force the adb service to restart like that:

sh-3.2# adb kill-server
sh-3.2# adb devices
* daemon not running; starting now at tcp:5037
* daemon started successfully

Then now you should be able to see a message on your phone asking if you authorise the computer.
Now you should be able to do your react-native run-android or yarn android

Start Google Cloud instance VM from a shared image from another Project / Organization

If you have multiple projects or organization and you want to clone a machine that is already configured, you can create an image of the instance of the machine.
But, you will have to share the access to the external project and organization.
Here is how to do it :

Share the image to the organization in the Images and in IAM

In both IAM and Image (VM) you will have to share the access Compute Image User

Start the VM using the shared image from another project / organization

gcloud compute instances create INSTANCE-NAME --image SHARED-IMAGE-NAME --image-project PROJECT-NAME --zone ZONE --tags http-server
  • INSTANCE-NAME : Name of the VM instance you are creating (that will appear in the VM list)
  • SHARED-IMAGE-NAME : The name of the image you shared to the organization
  • PROJECT-NAME : The name if the project where is the image you shared to the organization
  • ZONE : The geographical zone of the VM

Now the machine is started from an image from another organization and project !

Mac M1 : react native iOS mobile app on Simulator

I decided to make an article because I spent almost 5 days on this problem, and I don’t want it never happen. So let me help all the people that can be in the same case of me.

– You have a Mac M1 running on ARM 64 architecture
– You are working on a React Native or Swift project with Xcode

Exclude the ARM architecture in the Podfile

Add the following lines in the Podfile (/ios/Podfile) :

    post_install do |installer|
      ## FIX MAC M1 ARM
      react_native_post_install(installer)
      installer.pods_project.build_configurations.each do |config|
        config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
      end
    end

You should check that there is only one “post_install” in the file, if there is not you can add it at the end of the file, if there is already “post_install” somewhere, just put the instructions to exclude the architecture ARM 64 at the end of the “post_install” section.

Dependencies with CocoaPods

In the /ios folder of your React Native project, you should run the following command to build all the dependancy in the /Pods folder :

sudo arch -x86_64 pod install --allow-root

or, you can also use pod-install to be sure all is installed:

npx pod-install

In case of error: Delete /Pods folder, delete Podfile.lock and start again. In case of error of dependancies in node_modules, delete node_modules and run yarn.

Exclude the ARM architecture in Xcode

Now, you should also exclude the architecture in the project settings in Xcode :

Exclude the architecture “arm64” in Project > Build Settings > Architectures

Then if you start the react native project on Simulator it should works !