How to solve “gpg: public key decryption failed: Bad passphrase” in batch file

If you are trying to decrypt a file or a bunch of files using batch file in windows you will write something like this:

gpg --pinentry-mode=loopback --batch --yes --passphrase "abc%123" --decrypt-files *.pgp

and you put the above code in a .bat file and run it but you got an error like:

gpg: public key decryption failed: Bad passphrase

You are 1000% sure the passphrase is correct .. well the problem is in the passphrase itself as it contains a special character that needs to be escaped .. in the above example , the passphrase : “abc%123” must be written like this: “abc%%123” as %% is the escape of % … for a complete list of batch file escape characters , check this link

in case if you are wondering about the meaning of
–pinentry-mode=loopback  
it is used to prevent the gui from pooping up and asking for the passphrase.

Another important point , to make the batch option work without problem .. you have to make sure that the encrypted file extensions is *.pgp

Rendering path for HTML web page

Here is the steps the browser takes to render a web page after receiving the content from the server:

  1. Constructing the DOM Tree
  2. Constructing the CSSOM Tree
  3. Running JavaScript
  4. Creating the Render Tree
  5. Generating the Layout
  6. Painting

You can use Google chrome DevTool “Performance” to view rendering in progress with details and charts.

For more details, check this page: 

https://bitsofco.de/understanding-the-critical-rendering-path/

How to measure timing in Laravel using debugbar

If you want to measure the timing of some code in Laravel , you can use debugbar measure function

Debugbar::startMeasure('start');

Debugbar::stopMeasure('stop');

but if, for any reason, you can’t use debugbar, you can go back to pure php and use this code

 $start = microtime(true);
 
 $time_elapsed_secs = microtime(true) - $start;

 

How to test sending Laravel email from command prompt

If you want to test if you can send email from Laravel using only command prompt, here is how ..

  • First open your favorite command prompt
  • Go to your root folder of your website (i.e cd c:\xampp\htdocs\mySite )
  • Run this command: php artisan tinker
  • Mail::send(‘myView‘, [], function ($message) { $message->to(‘yourEmail@test.com’)->subject(‘Sending mail is OK’); });

How to configure virtual hosts on Apache on Windows

If you are using Apache on your Windows machine and want to set up virtual hosts so you can type something like this “www.myDomain.tst” in your browser and it’ll direct you to your local hosted site … you have to edit this file:

C:\WINDOWS\system32\drivers\etc\hosts

Add a new line with this text
127.0.0.1  myDomain

Open apache\conf\extra\httpd-vhosts.conf file and add these lines:

<VirtualHost *:80>
DocumentRoot path_to_your_document_root
ServerName myDomain
</VirtualHost>

Free DNS

There are a number of free DNS that you can use:

  • Google’s 8.8.8.8
  • Quad9’s 9.9.9.9
  • CloudFlare’s 1.1.1.1
  • OpenDNS  208.67.222.222
  • Norton 199.85.126.20
  • CleanBrowsing 185.228.168.168
  • Comodo DNS 8.26.56.26

Here is a good article comparing DNS for speed and features

For the speed results, The Top 5 DNS are:

Global Average Speed:

  1. CloudFlare: 4.98 ms
  2.  Google: 16.44 ms
  3.  Quad9: 18.25 ms
  4.  CleanBrowsing: 19.14 ms
  5.  Norton: 34.75 ms