What is coding ?

1 - Implement code
2 - DRY (Review Code Improvements) - Do not repeat yourself
3 - Unit Test
4 - Api Documentation + PHP DocBlock
5 - Code Styling PSR-2

There is a difference between hacking and coding. For business purposes developers tended to hack which is profitable for certain situation rather small environments. However when the team grows and when the code needs to be shared, it is ineluctable that some good practice needs to be setup. Unit tests guarantee the stability of your application for every and each incremental release/deployment of your application.

Get the developers to understand that point is critical. Explaining that this practice will allow them not to be blamed after each release, they will be stress free and confident is crucial.

Obviously, this comes with more work since you now need to test your code, and write unit test, making the task more strenuous, but this is indeed HARD WORK

Documenting as well is critical especially if supporting APIs, swagger comes handy for that purpose

Immutable File Unix reminder

lsattr /etc/pgbouncer/users.txt
 ----i--------e- /etc/pgbouncer/users.txt

lsattr /etc/pgbouncer/users.txt
----i--------e- /etc/pgbouncer/users.txt
 
sudo chattr -i /etc/pgbouncer/users.txt
lsattr /etc/pgbouncer/users.txt
 -------------e- /etc/pgbouncer/users.txt
 
vim /etc/pgbouncer/users.txt
sudo chattr +i /etc/pgbouncer/users.txt
lsattr /etc/pgbouncer/users.txt
----i--------e- /etc/pgbouncer/users.txt

Benefits of pull requests

  • Use this collaborative platform to discuss potential modifications to the code.
  • Improve code quality.
  • Simplify the process of receiving feedback from the reviewer.
  • Address feedback easily in-line near the relevant code.
  • Provide better stability for the code.

SSL ImportError: No module named cryptography

Problem – Let’s Encrypt

[root@ip-172-30-3-203 ec2-user]# /usr/local/bin/certbot-auto --no-bootstrap
 Creating virtual environment…
 Installing Python packages…
 Installation succeeded.
 Traceback (most recent call last):
   File "/opt/eff.org/certbot/venv/bin/letsencrypt", line 7, in 
     from certbot.main import main
   File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/certbot/main.py", line 2, in 
     from certbot._internal import main as internal_main
   File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/certbot/_internal/main.py", line 10, in 
     import josepy as jose
   File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/josepy/init.py", line 41, in 
     from josepy.interfaces import JSONDeSerializable
   File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/josepy/interfaces.py", line 7, in 
     from josepy import errors, util
   File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/josepy/util.py", line 7, in 
     import OpenSSL
   File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/OpenSSL/init.py", line 8, in 
     from OpenSSL import crypto, SSL
   File "/opt/eff.org/certbot/venv/local/lib/python2.7/dist-packages/OpenSSL/crypto.py", line 12, in 
     from cryptography import x509
 ImportError: No module named cryptography

Solution

rm -rf /opt/eff.org/*
pip install -U certbot
certbot renew --debug
 certbot

Best File compression

First, we installed Bastion and compressed its folder — about 863 MB in size of music, graphics, executable files, and various different types of documents:

  • Zip (Windows 8.1): 746 MB (86.4% of the original size)
  • Zip (WinZip): 745 MB (86.3% of the original size)
  • RAR (WinRAR): 746 MB (86.4% of the original size)
  • 7z (7-Zip): 734 MB (85% of the original size)

Next, we compressed Hotline Miami, which is 654 MB of data:

  • Zip (Windows 8.1): 316 MB (48.3% of the original size)
  • Zip (WinZip): 314 MB (48% of the original size)
  • RAR (WinRAR): 307 MB (46.9% of the original size)
  • 7z (7-Zip): 301 MB (46% of the original size)

How to collapse swagger tag categories by default ?

Add docExpansion:'true', in the file swagger/index.php

 <script>
    window.onload = function() {
      // Begin Swagger UI call region
      const ui = SwaggerUIBundle({
        //url: "http://davidr3.sbx.4over.com/swagger.json",
        url: "../swagger.json",
        dom_id: '#swagger-ui',
        docExpansion:'true',
        deepLinking: true,
        presets: [
          SwaggerUIBundle.presets.apis,
          SwaggerUIStandalonePreset
        ],
        plugins: [
          SwaggerUIBundle.plugins.DownloadUrl
        ],
        layout: "StandaloneLayout"
      })
      // End Swagger UI call region

      window.ui = ui
    }
  </script>