DeveloperBreeze

Validate Password Strength

// Function to check if a password meets certain strength criteria
function isValidPassword(password) {
    // Customize validation rules as needed
    const minLength = 8;
    const hasUppercase = /[A-Z]/.test(password);
    const hasLowercase = /[a-z]/.test(password);
    const hasDigit = /\d/.test(password);

    // Check if the password meets the criteria
    return password.length >= minLength && hasUppercase && hasLowercase && hasDigit;
}

// Example password
const password = 'SecurePwd123';

// Log whether the password is valid to the console
console.log('Is Valid Password:', isValidPassword(password));

Continue Reading

Discover more amazing content handpicked just for you

Tutorial
javascript

Running JavaScript in the Browser Console

     $0.style.color = "red";
  • Write multi-line code directly in the console:

Dec 10, 2024
Read More
Tutorial
python

Understanding Regular Expressions with `re` in Python

import re

# Pattern to match floating-point numbers
pattern = r"[+-]?\d+(\.\d+)?"

# Example text containing floating-point numbers
text = "Temperatures range from -3.5 to +27.85 degrees."

matches = re.findall(pattern, text)
print(matches)  # Output: ['-3.5', '+27.85']
  • The pattern r"[+-]?\d+(\.\d+)?" matches numbers like -3.5 and +27.85. It can handle both signed and unsigned numbers with a decimal point.

Oct 24, 2024
Read More
Tutorial
bash

How to Create SSL for a Website on Ubuntu

  • A server running Ubuntu (18.04, 20.04, or newer).
  • A domain name pointing to the server's public IP.
  • Root or sudo user privileges.
  • A web server such as Apache or Nginx installed.

Start by ensuring your server’s packages are up to date. Run the following commands:

Oct 21, 2024
Read More
Tutorial
javascript

Mastering console.log Advanced Usages and Techniques

console.count keeps track of how many times it has been called with a particular label, which can be useful for debugging loops or recursive functions.

function recursiveFunction(num) {
  console.count('Recursive function called');
  if (num > 0) recursiveFunction(num - 1);
}
recursiveFunction(5);
// Output: Recursive function called: 1, 2, 3, 4, 5, 6

Sep 02, 2024
Read More
Cheatsheet

VPN Services Cheat Sheet: Top Providers and Apps

  • Key Features:
  • No-log policy.
  • Secure Core servers (extra security).
  • P2P support.
  • Integrated with ProtonMail.
  • Free tier available.
  • Works with streaming services.
  • Pricing:
  • Free plan available.
  • $9.99/month (monthly plan).
  • $5.99/month (1-year plan).
  • $4.99/month (2-year plan).
  • Supported Platforms:
  • Windows, macOS, iOS, Android, Linux, routers.
  • Key Features:
  • 3,200+ servers in 80+ countries.
  • Patented Catapult Hydra protocol for speed.
  • 1Password integration.
  • Malware and phishing protection.
  • No-log policy.
  • Pricing:
  • Free plan (limited).
  • $12.99/month (monthly plan).
  • $7.99/month (1-year plan).
  • Supported Platforms:
  • Windows, macOS, iOS, Android, Linux, routers, Smart TVs.

Aug 21, 2024
Read More
Cheatsheet
python

Python Regular Expressions (Regex) Cheatsheet

text = "Contact me at 123-456-7890 or 987.654.3210"
phone_pattern = r'\d{3}[-.]\d{3}[-.]\d{4}'
phones = re.findall(phone_pattern, text)
print(phones)  # Output: ['123-456-7890', '987.654.3210']

This cheat sheet provides a quick reference to the most common regex patterns and functions in Python. For more complex regex patterns and usage, consider exploring the Python re module documentation.

Aug 03, 2024
Read More
Code
javascript

Parse JSON String to Object

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript

Convert Array of Objects to CSV

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript

Calculate Distance Between Two Points

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript

Calculate Greatest Common Divisor (GCD) of Two Numbers

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript

Detect Dark Mode Preference

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript

Detecting Browser and Version

// Immediately Invoked Function Expression (IIFE) to detect the browser and version
const browser = (function() {
    // Get user agent string from navigator
    const userAgent = navigator.userAgent;

    // Regular expression to match browser name and version
    const match = userAgent.match(/(chrome|firefox|safari|opera|edge|msie)\/(\d+(\.\d+)?)/i);

    // Return the detected browser information or 'Unknown' if not matched
    return match ? { name: match[1], version: match[2] } : 'Unknown';
})();

// Logging the detected browser information
console.log('Browser:', browser);

Jan 26, 2024
Read More
Code
php

Basic Authentication

$username = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
if ($username == 'admin' && $password == 'secret') {
    echo 'Authentication successful.';
} else {
    header('WWW-Authenticate: Basic realm="Restricted Area"');
    header('HTTP/1.0 401 Unauthorized');
    echo 'Authentication failed.';
    exit;
}

Jan 26, 2024
Read More
Code
javascript python +1

Generate Random Password

No preview available for this content.

Jan 26, 2024
Read More
Code
python

Bybit Futures API Integration Using ccxt Library with Error Handling

No preview available for this content.

Jan 26, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Start the discussion!