Skip to content

Instantly share code, notes, and snippets.

View andreipa's full-sized avatar
:octocat:
Loading knowledge...

Andrei Andrade andreipa

:octocat:
Loading knowledge...
View GitHub Profile
@andreipa
andreipa / modify-hosts-file
Last active March 23, 2021 13:02
How to modify hosts file in Windows, Mac and Linux
###### For Windows 10 and 8
1. Press the Windows key.
2. Type Notepad in the search field.
3. In the search results, right-click Notepad and select Run as administrator.
4. From Notepad, open the following file: c:\Windows\System32\Drivers\etc\hosts
5. Make the necessary changes to the file.
6. Click File > Save to save your changes.
###### For Windows 7 and Vista
@andreipa
andreipa / util_helpers.php
Created May 12, 2020 07:57
Remove html tags and truncate string adding a trim marker.
/**
* Remove html tags and truncate string
*
* @link https://www.php.net/manual/en/function.mb-strimwidth.php
* @author Andrei Andrade
*
* @param string $string The string being decoded.
* @param int $width The width of the desired trim.
* @param string $trimMarker A string that is added to the end of string when string is truncated.
*
@andreipa
andreipa / util_helpers.php
Created May 10, 2020 07:56
Validate Google reCaptcha with PHP.
/**
* Validate Google reCAPTCHA
*
* @link https://developers.google.com/recaptcha/docs/v3
* @author Andrei Andrade
*
* @param mixed $publicKey The shared key between your site and reCAPTCHA.
* @param mixed $privateKey The user response token provided by the reCAPTCHA client-side integration on your site.
* @param float $score Score value (1.0 is very likely a good interaction, 0.0 is very likely a bot).
* @param null|mixed $remoteIp Optional. The user's IP address.