Category Archives: Uncategorized

PHP Google reCAPTCHA v2

First you need to create the Google reCAPTCHA v2 key for your website. This is the HTML form example that shows the reCAPTCHA: * Replace YOUR_SITE_KEY_HERE with your site key * <form action="" method="post"> <div class="form-group" style="max-width: 303px;"> <input type="email" name="email" placeholder="Enter email here…" class="form-control" required email> </div> <div class="form-group"> <div class="g-recaptcha" data-sitekey="YOUR_SITE_KEY_HERE"></div> </div> <button […]

Get Photos and Videos from Instagram in PHP

Example PHP function to get the image and video url from Instagram: function get_instagram_image_url($url) { $result = array();   if(preg_match(‘/^https\:\/\/www\.instagram\.com\//is’, $url)) {   $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); $data = curl_exec($ch); curl_close($ch);   if(preg_match(‘/property\=\"og\:image\"\s+content\=\"(.+?)\"/is’, $data, $matches)) { $imageurl = trim($matches[1]);   if($imageurl) { if(preg_match(‘/property\=\"og\:video\"\s+content\=\"(.+?)\"/is’, $data, $matches)) { $videourl […]

Disable spell check on HTML text fields

Disable spell check, auto correct, auto capitalize on HTML text fields: <textarea autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false">Sample Nuit</textarea><textarea autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false">Sample Nuit</textarea> Disable spell check on HTML text fields: <textarea spellcheck="false">Sample Nuit</textarea><textarea spellcheck="false">Sample Nuit</textarea> Disable autocomplete on HTML text fields: <textarea autocomplete="off">Sample Nuit</textarea><textarea autocomplete="off">Sample Nuit</textarea> Disable auto correct on HTML text fields: <textarea autocorrect="off">Sample Nuit</textarea><textarea […]

Delphi 10 Berlin System.Hash MD5 SHA1 SHA2 Hash

You can create string and file hashes with System.Hash APIs: System.Hash – RAD Studio API Documentation Examples calculating string hashes: function GetStrHashMD5(Str: String): String; var HashMD5: THashMD5; begin HashMD5 := THashMD5.Create; HashMD5.GetHashString(Str); result := HashMD5.GetHashString(Str); end;   function GetStrHashSHA1(Str: String): String; var HashSHA: THashSHA1; begin HashSHA := THashSHA1.Create; HashSHA.GetHashString(Str); result := HashSHA.GetHashString(Str); end;   function […]

Standard ISO paper sizes, DPI and images size

List of DPI and image size in pixels for standard ISO paper sizes: A4 DPI and Image Size Type DPI Size (pixels) A4 300 DPI 3507×2480 A4 200 DPI 2338×1653 A4 150 DPI 1753×1240 A4 72DPI 841×595 A3 DPI and Image Size Type DPI Size (pixels) A3 300 DPI 4960×3507 A3 200 DPI 3307×2338 A3 […]

Download Google Chrome Full Standalone Offline Installer

Here are official links to download Google Chrome Full Standalone offline installer: Google Chrome Standalone Offline Installer (32-bit) Google Chrome Standalone Offline Installer (64-bit) If you need to install Google Chrome for all user accounts use these links: Google Chrome Offline Installer for All User Accounts (32-bit) Google Chrome Offline Installer for All User Accounts […]

PHP cURL curl_getinfo() Output

Example output of cURL curl_getinfo(): Array ( [url] => [content_type] => text/html; charset=iso-8859-1 [http_code] => 302 [header_size] => 304 [request_size] => 322 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.290086 [namelookup_time] => 0.06063 [connect_time] => 0.155486 [pretransfer_time] => 0.155554 [size_upload] => 0 [size_download] => 210 [speed_download] => 723 [speed_upload] => […]

PHP cURL Get Redirect URL as Variable

Get the redirect URL with cURL and PHP: function get_redirect_url($url, $referer) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20061204 Firefox/"); curl_setopt($ch, CURLOPT_REFERER, $referer); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_HEADER, false); $data = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); […]

PHP Find the Xth occurrence of a substring in a string

Function that use strpos() to get the Xth occurrence of a substring in a string: /** * Find the position of the Xth occurrence of a substring in a string * @param $haystack * @param $needle * @param $number integer > 0 * @return int */ function strposX($haystack, $needle, $number){ if($number == ‘1’){ return strpos($haystack, […]

PHP StrPos() Find Second Occurrence of a String

Simple PHP code to find the second occurrence of a string with strpos(): $pos1 = strpos($haystack, $needle); $pos2 = strpos($haystack, $needle, $pos1 + strlen($needle));$pos1 = strpos($haystack, $needle); $pos2 = strpos($haystack, $needle, $pos1 + strlen($needle)); You can make it a one-line like this: $pos2 = strpos($haystack, $needle, strpos($haystack, $needle) + strlen($needle));$pos2 = strpos($haystack, $needle, strpos($haystack, $needle) […]