Jump to content
Akinix
Sign in to follow this  

About This Club

Have any questions about Web Development? Ask here!

  1. What's new in this club
  2. Here is a super simple JavaScript code you could use on all websites which are using Cloudflare CDN. It allows you to quickly retrieve some connection data, such as IP, location, CF server, whether or not the user uses WARP VPN, etc. async function getCloudflareTraceJSON() { try { const response = await fetch(`https://${location.hostname}/cdn-cgi/trace`); const traceData = await response.text(); const traceEntries = traceData.trim().split('\n').map(e => e.split('=')); return Object.fromEntries(traceEntries); } catch (error) { console.error(error); return null; } } getCloudflareTraceJSON().then(console.log); Usage example: getCloudflareTraceJSON().then( traceData => { if (traceData.loc === 'US') { console.log('Location: USA'); } else { console.log('Location: Not USA'); } } );
  3. Use ad placeholders. Add empty divs where you want the ads to load and give them fixed widths/heights. This reserves the space before the ads load.
  4. [⁰¹²³⁴⁵⁶⁷⁸⁹] - all superscript numbers [₀₁₂₃₄₅₆₇₈₉] - all subscript numbers
  5. If you plan to use this as a nickname matcher, I recommend considering the following: /^[\p{L}\p{Mc}\p{Mn}\p{Nd}\p{P}\p{Zs}]+$/gmu This introduces stricter limitations for numbers, as it only allows decimal numbers and does not permit uncommon numbers like these: 𒐫 (Cuneiform Numeric Sign Nine Shar2) 𒐹 (Cuneiform Numeric Sign Five Buru) These characters are quite large and may have unpleasant effects on the layout and readability of nicknames. Additionally, it allows certain marks that must be permitted for some languages. It also allows punctuation characters, as some users may need them in their names. How it works \p{L}: Matches any Unicode letter. \p{Mc}: Matches a spacing combining mark (a character intended to be combined with another character). Explained below. \p{Mn}: Matches a non-spacing mark (a character intended to be combined with another character without taking up extra space). Explained below. \p{Nd}: Matches a decimal digit. \p{P}: Matches any kind of punctuation character. \p{Zs}: Matches a space separator (most common form being a space character). Why use \p{Mc} and \p{Mn} In many cases, letters with diacritical marks can be represented not just as a single Unicode symbol, but as a combination of a base symbol and a combining mark. These letters are very common in languages such as German, Norwegian, Turkish, and many others. It is not feasible to list all of them, but here is a selection of some common Latin script letters with diacritical marks. Keep in mind that this list is not exhaustive: Acute accent (´): á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý Grave accent (`): à, è, ì, ò, ù, À, È, Ì, Ò, Ù Circumflex (^): â, ê, î, ô, û, Â, Ê, Î, Ô, Û Tilde (~): ã, ñ, õ, Ã, Ñ, Õ Diaeresis/umlaut (¨): ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ Ring above (˚): å, Å Cedilla (¸): ç, Ç Ogonek (˛): ą, ę, Ą, Ę Macron (¯): ā, ē, ī, ō, ū, Ā, Ē, Ī, Ō, Ū Caron/háček (ˇ): č, ď, ě, ǧ, ǩ, ł, ń, ř, š, ť, ů, ž, Č, Ď, Ě, Ǧ, Ǩ, Ł, Ń, Ř, Š, Ť, Ů, Ž Breve (˘): ă, ĕ, ğ, ĭ, ŏ, ŭ, Ă, Ĕ, Ğ, Ĭ, Ŏ, Ŭ Dot above (˙): ż, Ż Double acute (˝): ő, ű, Ő, Ű Stroke (solidus): đ, ŧ, Đ, Ŧ These diacritical marks are applied to the Latin script used in various languages, such as French, Spanish, Portuguese, German, Polish, Romanian, and many others. Each language uses diacritical marks in unique ways to indicate changes in pronunciation, stress, or grammatical functions. Characters that match \p{Mc} (spacing combining marks) and \p{Mn} (non-spacing marks) are often used in languages that have diacritical marks or other modifiers for base letters. These marks can indicate different phonetic or tonal qualities. And it's not limited to Latin languages, it's widespread all around the world! Here are some examples of words and languages that use such characters: Devanagari (used in Hindi, Sanskrit, and other Indian languages): Word: काम (kām) - In this Hindi word, the ā (आ) vowel is represented by a spacing combining mark called a "matra" (ा) that is added to the base consonant क (ka). Vietnamese: Word: hẹn (hèn) - The 'è' vowel in this word is formed by adding a non-spacing mark called the "grave accent" (̀) to the base letter 'e'. The non-spacing mark 'dot below' (̣) is added to 'n' to form 'ṇ'. Arabic: Word: مُدَرِّس (mudarris) - This word has several non-spacing marks: the "damma" (ُ) above the م (m) and "kasra" (ِ) below the د (d), as well as "shadda" (ّ) above the ر (r), which indicates a doubled consonant. Hebrew: Word: שָׁלוֹם (shalom) - This word has a non-spacing mark called "kamatz" (ָ) under the ש (sh) and another non-spacing mark called "holam" (ֹ) above the ו (v) These are just a few examples of languages that use characters matching \p{Mc} and \p{Mn} to modify their base letters. There are many other languages and scripts that utilize combining marks to represent various phonetic and tonal features.
  6. /^[\p{L}\p{N}\p{Zs}]+$/gmu This regular expression pattern is used to match any string that consists of only letters, numbers, and whitespace characters. Let's break down the pattern: ^: asserts the start of the line. [\p{L}\p{N}\p{Zs}]+: matches one or more characters from any of the following Unicode character classes: \p{L}: any kind of letter from any language. \p{N}: any kind of numeric character in any script. \p{Zs}: a whitespace character that is not a line separator. $: asserts the end of the line. /g: the global flag, which means the pattern will be applied to the entire input string, rather than stopping after the first match. /m: the multiline flag, which means the pattern will be applied across multiple lines in the input string. /u: the Unicode flag, which makes the pattern work with Unicode characters. This regular expression can be used, for example, to check if a given string consists only of alphanumeric characters and spaces, with no special characters or punctuation.
  7. Hello, I'm looking for a solution. I need a regex that matches all letters, numbers, and spaces, not just in English but in all languages including Unicode characters. The popular example /^[a-zA-Z0-9\s]*$/ is not suitable as it only allows English letters.
  8. cacert.pem is required for cURL to work properly with HTTPS. Download the latest version of cacert.pem Then add the absolute path to this file in your php.ini in the "curl.cainfo" option, like this: curl.cainfo = C:\php\cacert.pem If you need more information about this, you can find it at https://curl.se/docs/caextract.html
  9. I keep getting an error in Laravel every time I try to make an HTTP request, even when using Guzzle. How can I fix this issue? Thank you! cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://example.com
  10. Thank you! It's working flawlessly, and I really appreciate your help! In the below code, I have added the Tailwind CSS classes to make it look more beautiful. <label for="range-input" class="text-lg font-medium text-gray-700">Select a value:</label> <div class="flex items-center mt-2"> <input type="range" id="range-input" name="range-input" min="0" max="100" value="50" class="flex-1 h-2 rounded-lg appearance-none bg-indigo-100 slider-thumb"> <input type="number" id="number-input" name="number-input" min="0" max="100" value="50" class="w-20 ml-2 py-1 text-center rounded-md bg-indigo-100 text-indigo-800"> </div> <script> const rangeInput = document.getElementById("range-input"); const numberInput = document.getElementById("number-input"); rangeInput.addEventListener("input", () => { numberInput.value = rangeInput.value; }); numberInput.addEventListener("input", () => { rangeInput.value = numberInput.value; }); </script>
  11. In HTML, you can use the input element with type="range" to create a slider control that allows users to select a value within a specified range. However, by default, the input element with type="range" does not allow users to manually type a value. If you want to allow users to type a number as well as use the slider control, you can use a combination of input elements with type="range" and type="number". Here's an example: <label for="range-input">Select a value:</label> <input type="range" id="range-input" name="range-input" min="0" max="100" value="50"> <input type="number" id="number-input" name="number-input" min="0" max="100" value="50"> <script> const rangeInput = document.getElementById("range-input"); const numberInput = document.getElementById("number-input"); rangeInput.addEventListener("input", () => { numberInput.value = rangeInput.value; }); numberInput.addEventListener("input", () => { rangeInput.value = numberInput.value; }); </script> In this example, we have a label element that describes the purpose of the inputs, followed by an input element with type="range" that has a min value of 0, a max value of 100, and an initial value of 50. We also have an input element with type="number" that has the same min and max values as the range input, and the same initial value. To connect the two inputs, we add some JavaScript code that listens for the input event on both inputs. When the range input changes, we update the value of the number input to match. And when the number input changes, we update the value of the range input to match. This ensures that the two inputs stay in sync with each other.
  12. I want to create an HTML input range that allows the user to enter a value by typing it in, in addition to using the slider control. I have read the documentation on MDN, but it seems that I can only create separate inputs for the range and the number. How can I combine the two inputs so that their values are in sync? Ensuring that they stay in sync when the user interacts with either input.
  13. This JavaScript code generates a dynamic table of contents (TOC) for a webpage based on the heading elements (h1 to h6) within the content wrappers. The generated TOC is a nested unordered list (ul) that reflects the hierarchy of the headings on the page, and is appended to the body of the page. Here's a step-by-step description of what the code does: The generateTOC() function is defined. Inside the function, all elements with the class .cPost_contentWrap are selected using querySelectorAll. Specify the container class of your content here instead of .cPost_contentWrap. A new unordered list (ul) element, toc, is created to serve as the table of contents container. For each content wrapper, the function selects all heading elements (h1 to h6) within the wrapper. For each heading element found, the following actions are performed: a. The heading level (1 to 6) is determined by extracting the number from the heading's tag name. b. A new list item (li) and anchor (a) elements are created. c. The anchor element's text content is set to the heading's text content, and its href is set to the heading's ID, creating a link to the heading. d. The anchor element is appended to the list item. e. A nested structure of unordered lists is built based on the heading level, and the list item is appended to the appropriate list. After iterating through all the headings in all the content wrappers, the generated table of contents (toc) is appended to the body of the page. Finally, the generateTOC() function is called, which creates and inserts the table of contents on the page. The resulting table of contents provides an organized, clickable list of the headings on the page, allowing users to navigate through the content more easily. This also has the added benefit of improving the page's SEO by providing a structured navigation system for search engines to crawl and index. function generateTOC() { const contentWrappers = document.querySelectorAll(".cPost_contentWrap"); // Specify the container class of your content here const toc = document.createElement("ul"); contentWrappers.forEach((wrapper) => { const headings = wrapper.querySelectorAll("h1, h2, h3, h4, h5, h6"); headings.forEach((heading) => { const level = parseInt(heading.tagName.slice(1)); const listItem = document.createElement("li"); const anchor = document.createElement("a"); anchor.textContent = heading.textContent; anchor.href = `#${heading.id}`; listItem.appendChild(anchor); let currentList = toc; for (let i = 1; i < level; i++) { if (!currentList.lastElementChild || currentList.lastElementChild.tagName !== "LI") { currentList.appendChild(document.createElement("li")); } if ( !currentList.lastElementChild.firstElementChild || currentList.lastElementChild.firstElementChild.tagName !== "UL" ) { currentList.lastElementChild.appendChild(document.createElement("ul")); } currentList = currentList.lastElementChild.firstElementChild; } currentList.appendChild(listItem); }); }); // Append the table of contents to the body of the page. document.body.appendChild(toc); } // Call the generateTOC function to create the table of contents generateTOC();
  14. Open Registry Editor Press Windows + R, type regedit, press Enter. Find the registry key that matches your default browser and make the necessary changes Microsoft Edge Navigate to Computer\HKEY_CLASSES_ROOT\MSEdgeHTM\shell\open\command Add the --incognito parameter to the value in (Default) after the path to the browser executable. You should get something like this: "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --incognito --single-argument %1 Google Chrome Navigate to Computer\HKEY_CLASSES_ROOT\ChromeHTML\shell\open\command Add the --incognito parameter to the value in (Default) after the path to the browser executable. You should get something like this: "C:\Program Files\Google\Chrome\Application\chrome.exe" --incognito --single-argument %1 Brave Navigate to Computer\HKEY_CLASSES_ROOT\BraveHTML\shell\open\command Add the --incognito parameter to the value in (Default) after the path to the browser executable. You should get something like this: "C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe" --incognito --single-argument %1 Firefox 1. Navigate to Computer\HKEY_CLASSES_ROOT\FirefoxURL\shell\open\command (FirefoxURL in the path may have an additional ending of letters and numbers in the name, for example FirefoxURL-308046B0AF4A39CB) 2. Replace -url parameter with -private-window parameter. You should get something like this: "C:\Program Files\Mozilla Firefox\firefox.exe" -osint -private-window "%1" 3. Navigate to Computer\HKEY_CLASSES_ROOT\FirefoxHTML\shell\open\command (FirefoxHTML in the path may have an additional ending of letters and numbers in the name, for example FirefoxHTML-308046B0AF4A39CB) 4. Do the same as in step 2.
  15. Check if you have php.ini in your php folder. Perhaps you forgot to create it from php.ini-development or php.ini-production.
  16. After upgrading to PHP 8, when I run "php artisan serve" I get the error "Failed to listen on 127.0.0.1:8000 (reason: ?)".
  17. Oracle Cloud Always Free cloud services: Two AMD Compute VMs Up to 4 instances of ARM Ampere A1 Compute with 3,000 OCPU hours and 18,000 GB hours per month Block, Object, and Archive Storage; Load Balancer and data egress; Monitoring and Notifications Two Oracle Autonomous Databases with powerful tools like Oracle APEX and Oracle SQL Developer https://www.oracle.com/cloud/free/#always-free
  18. In robots.txt: # Alexa: https://support.alexa.com/hc/en-us/articles/200450194-Alexa-s-Web-and-Site-Audit-Crawlers User-agent: ia_archiver Disallow: / # archive.org User-agent: archive.org_bot Disallow: / # Ahrefs: https://ahrefs.com/robot User-agent: AhrefsBot Disallow: / # MOZ: https://moz.com/help/moz-procedures/crawlers/rogerbot User-agent: rogerbot Disallow: / # MOZ: https://moz.com/help/moz-procedures/crawlers/dotbot User-agent: dotbot Disallow: / # DataForSeo https://dataforseo.com/dataforseo-bot User-agent: DataForSeoBot Disallow: / # Semrush: https://www.semrush.com/bot/ User-agent: SemrushBot Disallow: / User-agent: SiteAuditBot Disallow: / User-agent: SemrushBot-BA Disallow: / User-agent: SemrushBot-SI Disallow: / User-agent: SemrushBot-SWA Disallow: / User-agent: SemrushBot-CT Disallow: / User-agent: SemrushBot-BM Disallow: / User-agent: SplitSignalBot Disallow: / # Majestic: https://mj12bot.com/ User-agent: MJ12bot Disallow: / # SerpStat: https://serpstatbot.com/ User-agent: serpstatbot Disallow: / # MegaIndex: https://ru.megaindex.com/blog/seo-bot-detection User-agent: MegaIndexBot Disallow: / # SEO-PowerSuite-bot: https://www.link-assistant.com/seo-workflow/site-audit.html User-agent: SEO-PowerSuite-bot Disallow: / User-agent: * Disallow:
  19. You should use the "Require" rule instead of "order/allow/deny" directives. They are deprecated and will be removed in future version of apache server. E.g.: 1. When you need to deny access to specific files, then: Instead of this: <FilesMatch "(xmlrpc\.php|wp-trackback\.php)"> Order Allow,Deny Deny from all </FilesMatch> Use this: <FilesMatch "(xmlrpc\.php|wp-trackback\.php)"> Require all denied </FilesMatch> 2. When you need to allow access only from specific IP or range, use this: Require ip 103.21.244.0 # allow connections from specified IPv4 address Require ip 103.21.244.0/22 # allow connections from specified IPv4 range Require ip 2400:cb00::/32 # allow connections from specified IPv6 range # Allow connections only from CloudFlare (see https://www.cloudflare.com/ips/) Require ip 103.21.244.0/22 Require ip 103.22.200.0/22 Require ip 103.31.4.0/22 Require ip 104.16.0.0/13 Require ip 104.24.0.0/14 Require ip 108.162.192.0/18 Require ip 131.0.72.0/22 Require ip 141.101.64.0/18 Require ip 162.158.0.0/15 Require ip 172.64.0.0/13 Require ip 173.245.48.0/20 Require ip 188.114.96.0/20 Require ip 190.93.240.0/20 Require ip 197.234.240.0/22 Require ip 198.41.128.0/17 Require ip 2400:cb00::/32 Require ip 2606:4700::/32 Require ip 2803:f800::/32 Require ip 2405:b500::/32 Require ip 2405:8100::/32 Require ip 2a06:98c0::/29 Require ip 2c0f:f248::/32
  20. As a developer, I’ll often hear about “slow page load”. Of course, I’m not the only one in this boat. We’ve grown used to visiting sites that perform phenomenally, which adds to how unbearable the experience feels with ones that don’t. There could be multiple reasons behind a slow loading website. One issue that Magento store owners especially tend to face is down to the hundreds of images on their web page. I personally like the Magento 2 lazy load extension with its minimal but excellent features. Should I give it a try.
  21. As far as I know, the only way to deal with it at this time is to set container height manually.
  22. Is there any good solution for fixing the Cumulative Layout Shift (CLS) caused by Google AdSense? How do you deal with it?
  23.  
×
×
  • Create New...